0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-05 02:06:27 +00:00
OI-codes/Luogu/P1093/P1093.cpp

44 lines
953 B
C++
Raw Normal View History

2021-11-19 09:01:13 +00:00
#include <bits/stdc++.h>
2020-10-25 09:04:23 +00:00
using namespace std;
struct node {
int chinese, math, english, all, id;
2021-11-19 09:01:13 +00:00
2020-10-25 09:04:23 +00:00
node() {
id = chinese = math = english = all = 0;
}
node(int _id, int _chinese, int _math, int _english) {
id = _id;
chinese = _chinese;
math = _math;
english = _english;
all = chinese + math + english;
}
};
bool cmp(node a, node b) {
2021-11-19 09:01:13 +00:00
if (a.all == b.all) {
if (a.chinese == b.chinese) {
2020-10-25 09:04:23 +00:00
return a.id < b.id;
}
return a.chinese > b.chinese;
}
return a.all > b.all;
}
int main() {
int n;
node a[305];
cin >> n;
2021-11-19 09:01:13 +00:00
for (int i = 0; i < n; i++) {
2020-10-25 09:04:23 +00:00
cin >> a[i].chinese >> a[i].math >> a[i].english;
a[i].all = a[i].chinese + a[i].math + a[i].english;
2021-11-19 09:01:13 +00:00
a[i].id = i + 1;
2020-10-25 09:04:23 +00:00
}
2021-11-19 09:01:13 +00:00
sort(a, a + n, cmp);
for (int i = 0; i < 5; i++) {
2020-10-25 09:04:23 +00:00
cout << a[i].id << ' ' << a[i].all << endl;
}
return 0;
}