http://acm.hdu.edu.cn/showproblem.php?pid=1070
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
struct node
{
string str;
int m;
int v;
int day;
double s;
};
double cmp(node& x,node& y)
{
if(x.s!=y.s)
return x.s<y.s;
else return x.v>y.v;
}
int main()
{
int t,n,i;
cin>>t;
vector<node> a;
node f;
while(t--)
{
cin>>n;
int k=0;
for(i=0;i<n;i++)
{
cin>>f.str>>f.m>>f.v;
f.day=f.v/200;
if(f.v<200) continue;
if(f.day>5) f.day=5;
f.s=1.0*f.m/f.day;
a.push_back(f);
k++;
}
sort(a.begin(),a.end(),cmp);
// for(i=0;i<a.capacity();i++)
cout<<a.front().str<<endl;
a.clear();
}
return 0;
}
#include <stdio.h>
#include <string.h>
int main()
{
char m[100],d[100];
int t,n,a,b,c,aa,bb,cc;
scanf("%d", &t);
while(t-- && scanf("%d", &n))
{
aa = 100000;
cc = bb = 1;
while(n-- && scanf("%s %d %d", m, &a, &b))
{
if(b < 200) continue;
c = b/200 < 5 ? b/200 : 5;
if(aa*c > a*cc)
{
aa = a;
bb = b;
cc = c;
printf("%d %d\n",aa,bb);
strcpy(d, m);
}
else if(aa*c == a*c && b > bb)
{
bb = b;
strcpy(d, m);
}
}
puts(d);
}
return 0;
}
浙公网安备 33010602011771号