AcWing 429. 奖学金
原题链接
简单
作者:
Rwt
,
2021-02-13 23:55:24
,
所有人可见
,
阅读 267
#include <bits/stdc++.h>
using namespace std;
struct node //考试成绩结构体
{
int id, yuwen, shuxue, yingyu, zongfen;
bool operator<(struct node x) const
{
return tie(x.zongfen, x.yuwen, id) < tie(zongfen, yuwen, x.id);
}
} s[310];
int main()
{
int n;
cin >> n;
for (int i = 1; i <= n; i++)
{
s[i].id = i;
cin >> s[i].yuwen >> s[i].yingyu >> s[i].shuxue;
s[i].zongfen = s[i].yuwen + s[i].yingyu + s[i].shuxue;
}
sort(s + 1, s + n + 1);
for (int i = 1; i <= 5; i++)
cout << s[i].id << " " << s[i].zongfen << endl;
return 0;
}