-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10814.cpp
More file actions
52 lines (51 loc) · 968 Bytes
/
10814.cpp
File metadata and controls
52 lines (51 loc) · 968 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
41
42
43
44
45
46
47
48
49
50
51
52
#include <stdio.h>
#include <string.h>
#include <string>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <deque>
#pragma warning(disable:4996)
#define _CRT_SECURE_NO_WARNINGS
using namespace std;
typedef struct point {
int age;
string name;
int num;
};
bool check(const point &s1, const point &s2) {
if (s1.age == s2.age) {
return s1.num < s2.num;
}
return s1.age < s2.age;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
vector<point> pu;
int age[201] = { 0, };
int n;
cin >> n;
int sum=0;
for (int i = 0; i < n; i++) {
point a;
cin >> a.age >> a.name;
if (age[a.age] != 0) {
a.num = age[a.age] + 1;
age[a.age]++;
}
else {
a.num = 1;
age[a.age]++;
}
pu.push_back(a);
}
sort(pu.begin(), pu.end(), check);
vector<point>::iterator iter;
for (iter = pu.begin(); iter != pu.end(); iter++) {
cout << (*iter).age<<" "<< (*iter).name<<"\n";
}
return 0;
}