-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10814.cpp
More file actions
36 lines (31 loc) · 729 Bytes
/
10814.cpp
File metadata and controls
36 lines (31 loc) · 729 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
#include <iostream>
#include <vector>
#include <algorithm>
#define io ios::sync_with_stdio(false); cin.tie(0);
using namespace std;
class consumer{
public:
int age;
string name;
int index;
bool operator <(consumer &a){
if(this->age==a.age) return this->index<a.index;
else return this->age < a.age;
}
};
int main()
{
io;
int N;
cin>>N;
vector<consumer> arr(N);
vector<consumer> result(N);
for(int i=0;i<N;i++){
cin>>arr[i].age>>arr[i].name;
arr[i].index=i;
result[i]=arr[i];
}
sort(result.begin(),result.end());
for(int i=0;i<N;i++) cout<<result[i].age<<' '<<result[i].name<<'\n';
return 0;
}