0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-10 05:18:49 +00:00

P1093 奖学金

R40503360
This commit is contained in:
Baoshuo Ren 2020-10-25 17:04:23 +08:00 committed by Baoshuo Ren
parent 1dd1d5a132
commit 8d3e6bb39a
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

44
problem/P1093/P1093.cpp Normal file
View File

@ -0,0 +1,44 @@
#include<bits/stdc++.h>
using namespace std;
struct node {
int chinese, math, english, all, id;
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) {
if(a.all == b.all) {
if(a.chinese == b.chinese) {
return a.id < b.id;
}
return a.chinese > b.chinese;
}
return a.all > b.all;
}
int main() {
int n;
node a[305];
cin >> n;
for(int i = 0 ; i < n ; i++) {
cin >> a[i].chinese >> a[i].math >> a[i].english;
a[i].all = a[i].chinese + a[i].math + a[i].english;
a[i].id = i+1;
}
sort(a, a+n, cmp);
for(int i = 0 ; i < 5 ; i++) {
cout << a[i].id << ' ' << a[i].all << endl;
}
return 0;
}