#include <iostream>
#include <algorithm>
using namespace std;
struct student{
string name;
int m,e,c,pai, zong;//m:数学 e:英语 c:语文 pai:顺序 zong:总分
};
bool cmp(student a, student b){
if(a.zong == b.zong){
return a.zong > b.zong;
}else{
return a.pai < b.pai;
}
}
int main(){
int n;
student stu[1010];
cin >>n;
for(int i = 0; i < n; i++){
cin >> stu[i].name >> stu[i].c >> stu[i].m >> stu[i].e;
stu[i].pai = i;
stu[i].zong = stu[i].c + stu[i].m + stu[i].e;
}sort(stu, stu + n, cmp);
cout << stu[0].name << ' ' << stu[0].c << ' ' << stu[0].m << ' ' << stu[0].e;
return 0;
}
样例过了然而零分
注释是我自己打的(谁抄完题解会来讨论区问啊【doge】)