每次读入的时候就把这个人的分数算出来,如果是最大的就把最大值更新一下即可。
Code:
#include <map>
#include <stack>
#include <queue>
#include <cmath>
#include <cctype>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define Max(a,b) ((a)>(b)?(a):(b))
#define Min(a,b) ((a)<(b)?(a):(b))
bool cmp(const int a, const int b)
{
return a > b;
}
int main()
{
int cases=0;
scanf("%d",&cases);
int max=-2999;
string win="";
for(int _case=1;_case<=cases;_case++)
{
string name;
int p,m,a,b,c,d,e,score;
cin>>name>>p>>m>>a>>b>>c>>d>>e;
score=p*100-m*50+a+b+c+d+e;
if (score>max) max=score,win=name;
}
cout<<win;
return 0;
}