429. 奖学金
作者:
jy9
,
2024-07-01 10:28:04
,
所有人可见
,
阅读 3
#include <iostream>
#include <algorithm>
#define int long long
using namespace std;
const int N = 310;
struct score{
int chinese, math, english,id;
bool operator < (const score &p)const{
if((chinese+math+english) > (p.chinese+p.math+p.english))return true;
else if((chinese+math+english) < (p.chinese+p.math+p.english))return false;
if ((chinese+math+english) == (p.chinese+p.math+p.english)){
if(chinese == p.chinese)return id<p.id;
return chinese>p.chinese;
}
}
}a[N];
signed main(){
int n;
cin >> n;
for (int i = 1; i <= n; i ++ ){
cin >> a[i].chinese >> a[i].math >> a[i].english;
a[i].id = i;
}
sort(a+1, a+1+n);
for (int i = 1; i <= 5; i ++ ){
cout << a[i].id << ' ' << a[i].chinese+a[i].math+a[i].english << endl;
}
return 0;
}