mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-12-24 03:31:59 +00:00
P1093 奖学金
R40503360
This commit is contained in:
parent
1dd1d5a132
commit
8d3e6bb39a
44
problem/P1093/P1093.cpp
Normal file
44
problem/P1093/P1093.cpp
Normal 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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user