forked from ndb796/python-for-coding-test
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path1.cpp
More file actions
58 lines (52 loc) ยท 1.48 KB
/
1.cpp
File metadata and controls
58 lines (52 loc) ยท 1.48 KB
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
49
50
51
52
53
54
55
56
57
58
#include <bits/stdc++.h>
using namespace std;
class Student {
public:
string name;
int kor;
int eng;
int m;
Student(string name, int kor, int eng, int m) {
this->name = name;
this->kor = kor;
this->eng = eng;
this->m = m;
}
/*
[ ์ ๋ ฌ ๊ธฐ์ค ]
1) ๋ ๋ฒ์งธ ์์๋ฅผ ๊ธฐ์ค์ผ๋ก ๋ด๋ฆผ์ฐจ์ ์ ๋ ฌ
2) ๋ ๋ฒ์งธ ์์๊ฐ ๊ฐ์ ๊ฒฝ์ฐ, ์ธ ๋ฒ์งธ ์์๋ฅผ ๊ธฐ์ค์ผ๋ก ์ค๋ฆ์ฐจ์ ์ ๋ ฌ
3) ์ธ ๋ฒ์งธ ์์๊ฐ ๊ฐ์ ๊ฒฝ์ฐ, ๋ค ๋ฒ์งธ ์์๋ฅผ ๊ธฐ์ค์ผ๋ก ๋ด๋ฆผ์ฐจ์ ์ ๋ ฌ
4) ๋ค ๋ฒ์งธ ์์๊ฐ ๊ฐ์ ๊ฒฝ์ฐ, ์ฒซ ๋ฒ์งธ ์์๋ฅผ ๊ธฐ์ค์ผ๋ก ์ค๋ฆ์ฐจ์ ์ ๋ ฌ
*/
bool operator <(Student &other) {
if (this->kor == other.kor && this->eng == other.eng && this->m == other.m) {
return this->name < other.name;
}
if (this->kor == other.kor && this->eng == other.eng) {
return this->m > other.m;
}
if (this->kor == other.kor) {
return this->eng < other.eng;
}
return this->kor > other.kor;
}
};
int n;
vector<Student> v;
int main(void) {
cin >> n;
for (int i = 0; i < n; i++) {
string name;
int kor;
int eng;
int m;
cin >> name >> kor >> eng >> m;
v.push_back(Student(name, kor, eng, m));
}
sort(v.begin(), v.end());
// ์ ๋ ฌ๋ ํ์ ์ ๋ณด์์ ์ด๋ฆ๋ง ์ถ๋ ฅ
for (int i = 0; i < n; i++) {
cout << v[i].name << '\n';
}
}