-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathboj10814.cpp
49 lines (44 loc) · 857 Bytes
/
boj10814.cpp
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
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <functional>
#include <set>
#include <queue>
using namespace std;
typedef struct t{
int age;
string name;
int index;
t(int a, string b, int c){
age = a;
name = b;
index = c;
}
}t;
inline void Quick_IO(){
ios_base :: sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
}
vector<t> arr;
int main(){
Quick_IO();
int n;
cin>>n;
for (int i = 0; i < n; ++i) {
int a;
string b;
cin>>a>>b;
arr.emplace_back(a, b, i);
}
sort(arr.begin(), arr.end(), [](t a, t b){
if(a.age==b.age) return a.index<b.index;
return a.age<b.age;
});
for(const auto& x:arr){
cout<<x.age<<" "<<x.name<<"\n";
}
return 0;
}