solution
2024-08-22 20:46:05
发布于:广东
0阅读
0回复
0点赞
#include <bits/stdc++.h>
using namespace std;
struct node{
int c;
int m;
int e;
int id;
int sum;
}a[310];
bool cmp(node a, node b){
if(a.sum != b.sum) return a.sum > b.sum;
else if(a.c != b.c) return a.c > b.c;
else return a.id < b.id;
}
int main(){
int n;
cin >> n;
for(int i = 1; i <= n; i++){
cin >> a[i].c >> a[i].m >> a[i].e;
a[i].id = i;
a[i].sum = a[i].c + a[i].m + a[i].e;
}
sort(a + 1, a + n + 1, cmp);
for(int i = 1; i <= 5; i++){
cout << a[i].id << ' ' << a[i].sum << endl;
}
return 0;
}
这里空空如也
有帮助,赞一个