-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path[BOJ] 10825 국영수(정렬).cpp
More file actions
48 lines (41 loc) · 893 Bytes
/
[BOJ] 10825 국영수(정렬).cpp
File metadata and controls
48 lines (41 loc) · 893 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
struct Person {
string name;
int kor, eng, math;
};
bool cmp(const Person &u, const Person &v) {
if (u.kor > v.kor) {
return true;
}
else if (u.kor == v.kor) {
if (u.eng < v.eng) {
return true;
}
else if (u.eng == v.eng) {
if (u.math > v.math) {
return true;
}
else if (u.math == v.math) {
return u.name < v.name;
}
}
}
return false;
}
int main() {
int n;
cin >> n;
vector<Person> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i].name >> a[i].kor >> a[i].eng >> a[i].math;
}
sort(a.begin(), a.end(), cmp);
for (int i = 0; i < n; i++) {
cout << a[i].name << '\n';
}
return 0;
}