HDU2570

#include<stdio.h>

#include<stdlib.h>

int cmp( const void *a , const void *b ) 

{ 

	return *(double *)a > *(double *)b ? 1 : -1; 

}

int main(){

	int t,i,j,n,v,ansv,tpcnt;

	double s,ansp,tp;

	double a[110];

	scanf("%d",&t);

	while(t--){

	scanf("%d%d%lf",&n,&v,&s);

	for(i=0;i<n;i++){

		scanf("%lf",&a[i]);

	}

	qsort(a,n,sizeof(a[0]),cmp);

	tpcnt=0;tp=0;ansv=0;

	for(i=0;i<n;i++){

		tp+=a[i];

		tpcnt++;

		if((1.0*tp/tpcnt)<=s){

			ansp=1.0*tp/tpcnt;

			ansv=1.0*tpcnt;

		}

		else

			break;

	}

	if(ansv==0)

		printf("0 0.00\n");

	else

		printf("%d %.2lf\n",ansv*v,ansp/100);

	}

	return 0;

}

  注意精度!!!

你可能感兴趣的:(HDU)