hdu 1070


生活上的白痴哭


最开始比单价,单价相同肯定买多的啊!!!虽然我不会,长胖。。。。


#include <iostream>
#include <stdio.h>
using namespace std;

struct node
{
    char str[105];
    int price;
    double ave;
    int vol;
}milk[105];

int main()
{
    //freopen("in.txt","r",stdin);
    int t;
    scanf("%d",&t);
    while(t--)
    {
        node chp;
        chp.ave=0xffffff;
        int n;
        scanf("%d",&n);
        for(int i=0;i<n;i++)
        {
            scanf("%s%d%d",milk[i].str,&milk[i].price,&milk[i].vol);
            if(milk[i].vol<200)continue;
            int day=0;
            while(milk[i].vol>=200)
            {
                milk[i].vol-=200;
                day++;
                if(day==5)break;

            }
            if(day)
            {
                if((double)milk[i].price/day<chp.ave)
                {
                    chp=milk[i];
                    chp.ave=(double)chp.price/day;
                }
                else if((double)milk[i].price/day==chp.ave)
                {
                    if(milk[i].vol>chp.vol)
                    {
                        chp=milk[i];
                    }
                }
            }
        }
        printf("%s\n",chp.str);
    }
    return 0;
}



你可能感兴趣的:(hdu 1070)