您的位置:首页 > 其它

HDU 2570 迷瘴

2013-04-04 16:26 363 查看
浓度按照从小到大排序,一直累加到超过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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: