还以为TLE了
2024-08-23 12:02:22
发布于:广东
1阅读
0回复
0点赞
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
struct node{
string name;
int gold;
int silver;
int bronze;
int sum;
int id;
}medal[maxn];
bool cmp(node a, node b){
if(a.sum != b.sum) return a.sum > b.sum;
else if(a.gold != b.gold) return a.gold > b.gold;
else if(a.silver != b.silver) return a.silver > b.silver;
else return a.id < b.id;
}
int main(){
int n;
cin >> n;
for(int i = 1; i <= n; i++){
cin >> medal[i].name >> medal[i].gold >> medal[i].silver >> medal[i].bronze;
medal[i].sum = medal[i].gold + medal[i].silver + medal[i].bronze;
medal[i].id = i;
}
sort(medal + 1, medal + n + 1, cmp);
for(int i = 1; i <= n; i++){
cout << medal[i].name << ' ' << medal[i].sum;
cout << "\n";
}
return 0;
}
这里空空如也
有帮助,赞一个