hdu1070水题找感觉

#include <iostream>
using namespace std;

int T,N;

typedef struct
{
	string brand;
	int P;
	int V;
}milk;

milk milks[100+1];

int main()
{
	cin>>T;
	while(T--)
	{
		cin>>N;
		for(int i = 0; i < N; i++)
		{
			cin>>milks[i].brand>>milks[i].P>>milks[i].V;
		}
		
		double price;
		int maxi;
		double maxp;
		maxp = 65535;
		for(int i = 0; i < N; i++)
		{
			if(milks[i].V > 1000)
			{
				price = 1.0*milks[i].P/5; 	
			}
			else if(milks[i].V < 200)
			{
				
			}
			else
			{
				price = 1.0*milks[i].P/(milks[i].V/200);	
			}
			if(maxp > price)
			{
				maxi = i;
				maxp = price;
			}
			if(maxp == price)
			{
				if(milks[i].V > milks[maxi].V)
				{
					maxi = i;
				}
			}
		}

		cout<<milks[maxi].brand<<endl;
	}
	return 0;
}

你可能感兴趣的:(hdu1070水题找感觉)