hdu1070 Milk

#include <stdio.h>
#include <string.h>

int main()
{
	int test,n,P,V,days,vmax;
	double avg,avgmin;
	char brand[102],ansBrand[102];
	scanf("%d",&test);
	while(test--)
	{
		scanf("%d",&n);
		vmax=0;
		avgmin=100000.0;
		while(n--)
		{
			scanf("%s %d %d",brand,&P,&V);
			if(V<200)
				continue;
			if(V>=1000)
				avg=1.0*P/5;
			else
			{
				days=V/200;
				avg=1.0*P/days;
			}
			if(avg<avgmin||avg==avgmin&&V>vmax)
			{
				avgmin=avg;
				vmax=V;
				strcpy(ansBrand,brand);
			}
		}
		if(avgmin==100000.0)
			continue;
		else
			printf("%s\n",ansBrand);
	}
	return 0;
}

你可能感兴趣的:(hdu1070 Milk)