AcWing 429. 奖学金
原题链接
简单
#include<bits/stdc++.h>
using namespace std;
int n;
struct pai{
int c,m,e;
int z;
int x;
}a[310];
bool cmp(pai a,pai b){
if(a.z!=b.z){
return a.z>b.z;
}else if(a.z==b.z && a.c!=b.c){
return a.c>b.c;
}else if(a.z==b.z && a.c==b.c && a.x!=b.x){
return a.x<b.x;
}
}
int main(){
cin >> n;
for(int i=0;i<n;i++){
cin >> a[i].c >> a[i].m >> a[i].e;
a[i].z=a[i].c+a[i].m+a[i].e;
a[i].x=i+1;
}
sort(a,a+n,cmp);
for(int i=0;i<5;i++){
cout << a[i].x << ' ' << a[i].z << endl;
}
return 0;
}