hdu1070Milk

来源:互联网 发布:linuxwifi渗透软件 编辑:程序博客网 时间:2024/05/16 15:02
题目链接: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;}

0 0
原创粉丝点击