AcWing 429. 奖学金
原题链接
简单
作者:
Value
,
2020-09-08 17:49:34
,
所有人可见
,
阅读 478
概率低确实, 学号在后面的还是挺惨的!
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 310;
struct node{
int c, sum;
int id;
}student[N];
bool cmp(node a, node b){
if(a.sum != b.sum) return a.sum > b.sum;
if(a.c != b.c) return a.c > b.c;
return a.id < b.id;
}
int main(){
int n; cin >> n;
for(int i = 0; i < n; i ++ ){
int c, m, e; cin >> c >> m >> e;
student[i].id = i + 1;
student[i].c = c;
student[i].sum = c + m + e;
}
sort(student, student + n, cmp);
for(int i = 0; i < 5; i ++ )
cout << student[i].id << ' ' << student[i].sum << endl;
return 0;
}