浓度按照从小到大排序,一直累加到超过W就可以停了,该死的比例转来转去头都晕了.
#include <iostream>
#include <algorithm>
#include <memory.h>
#include <cstdio>
using namespace std;
const int maxn=110;
int P[maxn],n,V,W;
int main(){
int t;
scanf("%d",&t);
while (t--)
{
scanf("%d%d%d",&n,&V,&W);
for (int i=0;i<n;++i)scanf("%d",&P[i]);
sort(P,P+n);
int ansV=0,sum=0;
double mul=100.0/V,ansP=0.0;;
for (int i=0;i<n;++i)
{
sum+=P[i];
double t=sum/((double)(i+1)*V*mul);
if(t<=W/100.0&&ansV<(i+1)*V){
ansV=(i+1)*V;
ansP=t;
}else break;
}
printf("%d %.2lf\n",ansV,ansP);
}
return 0;
}