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
|
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
bool compare(pair<int, pair<string, int>> v1, pair<int, pair<string, int>> v2) {
if (v1.second.second != v2.second.second) {
return v1.second.second > v2.second.second;
}
else {
return v1.first < v2.first;
}
}
int main() {
vector<pair<int, pair<string, int>>> v;
for (int i = 0; i < 5; i++) {
string name;
int score;
cin >> name >> score;
v.push_back(pair<int, pair<string, int>>(i, make_pair(name, score)));
}
sort(v.begin(), v.end(), compare);
for (int i = 0; i < v.size(); i++) {
cout << v[i].second.first << endl;
}
}
|
cs |
'C,C++ > Algorithm' 카테고리의 다른 글
Algorithm, c++, Heap sort (0) | 2019.09.23 |
---|---|
Algorithm, c++, BFS와 DFS 구현 (0) | 2019.09.23 |