fee600 @ 2022-07-21 10:36:08
#include <bits/stdc++.h>
using namespace std;
struct qwer {
string m;
int a, x, y, z;
} qq[1010];
int cmp(qwer x, qwer y) {
return x.a > y.a;
}
int main() {
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> qq[i].m;
cin >> qq[i].x >> qq[i].y >> qq[i].z;
qq[i].a = qq[i].x + qq[i].y + qq[i].z;
/*if (qq[i].a > maxx) {
maxx = qq[i].a;
maxxn = qq[i].m;
x1 = qq[i].x;
x2 = qq[i].y;
x3 = qq[i].z;
}*/
}
sort(qq + 1, qq + n + 1, cmp);
cout << qq[1].m << " " << qq[1].x << " " << qq[1].y << " " << qq[1].z;
return 0;
}
by Purple_Circle @ 2022-07-22 14:33:55
@fee600
qq[1]的总分要初始化为-1,否则会遇到总分为0而无法更新的情况
by F_oR_es_T @ 2022-07-24 12:07:59
@fee600 好好看看题目描述最后一句话
by fee600 @ 2022-07-24 14:13:06
好了,过了。
by jisp123 @ 2022-08-01 19:08:35
@邓睿朗 总分都为零不就不用更新了吗,自动输出第一个结果。他代码跑下来和第一个样例的output是一样的啊,还是没太明白为啥90分。
by _H17_ @ 2022-08-02 20:24:03
CMP中若这两项的成绩不相同:
则返回谁总成绩更大,否则返回编号更小的。