forked from ndb796/python-for-coding-test
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path11.cpp
More file actions
40 lines (33 loc) ยท 801 Bytes
/
11.cpp
File metadata and controls
40 lines (33 loc) ยท 801 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
#include <bits/stdc++.h>
using namespace std;
class Student {
public:
string name;
int score;
Student(string name, int score) {
this->name = name;
this->score = score;
}
// ์ ๋ ฌ ๊ธฐ์ค์ '์ ์๊ฐ ๋ฎ์ ์์'
bool operator <(Student &other) {
return this->score < other.score;
}
};
int n;
vector<Student> v;
int main(void) {
// N์ ์
๋ ฅ๋ฐ๊ธฐ
cin >> n;
// N๋ช
์ ํ์ ์ ๋ณด๋ฅผ ์
๋ ฅ๋ฐ์ ๋ฆฌ์คํธ์ ์ ์ฅ
for (int i = 0; i < n; i++) {
string name;
int score;
cin >> name >> score;
v.push_back(Student(name, score));
}
sort(v.begin(), v.end());
// ์ ๋ ฌ์ด ์ํ๋ ๊ฒฐ๊ณผ๋ฅผ ์ถ๋ ฅ
for(int i = 0; i < n; i++) {
cout << v[i].name << ' ';
}
}