forked from mpfeifer1/Kattis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgrandpabernie.cpp
56 lines (43 loc) · 1.03 KB
/
grandpabernie.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
50
51
52
53
54
55
56
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
int n;
cin >> n;
unordered_map<string, vector<int>> vacations;
unordered_set<string> destinations;
for(int i = 0; i < n; i++) {
string dest;
cin >> dest;
int year;
cin >> year;
destinations.insert(dest);
if(vacations.count(dest) < 1) {
vector<int> v;
v.push_back(year);
vacations.insert({dest, v});
}
else {
vector<int>& temp = vacations[dest];
temp.push_back(year);
}
}
int m;
cin >> m;
for(auto d : destinations) {
vector<int>& temp = vacations[d];
sort(temp.begin(), temp.end());
}
for(int i = 0; i < m; i++) {
string dest;
cin >> dest;
int trip;
cin >> trip;
vector<int>& temp = vacations[dest];
cout << temp[trip-1] << endl;
}
}