您的位置:首页 > 其它

hdu1070Milk

2016-04-23 00:37 274 查看
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1070

水。

代码:
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

struct Node{
char s[105];
int price;
int v;
double perPrice;
}a[105];

bool cmp(Node x,Node y)

{
if(x.perPrice != y.perPrice)
return x.perPrice < y.perPrice;
else if(x.v != y.v)
return x.v > y.v;
}

int main()

{
int _;
scanf("%d",&_);
while(_--)
{
memset(a,0,sizeof(a));
int n;
scanf("%d",&n);
for(int i = 0;i < n;++i)
{
scanf("%s%d%d",a[i].s,&a[i].price,&a[i].v);
if(a[i].v / 200)
{
int t = a[i].v / 200;
if(t > 5)
t = 5;
a[i].perPrice = (double)a[i].price / t;
}
}
sort(a,a + n,cmp);
for(int i = 0;i < n;++i)
{
if(a[i].perPrice)
{
printf("%s\n",a[i].s);
break;
}
}
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: