-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path700_24en23P.cpp
47 lines (41 loc) · 865 Bytes
/
700_24en23P.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
// Usuario de Acepta el reto: jjjjjjjp022
#include <iostream>
#include <vector>
#include <unordered_map>
#include <algorithm>
using namespace std;
using lli = long long int;
bool cmp(const pair<lli, string>& a, const pair<lli, string>& b)
{
return a.first < b.first || (a.first == b.first && a.second > b.second);
}
int main() {
int n;
cin >> n;
while(n != 0) {
lli aux;
string p;
char c;
unordered_map<string, lli> tiempo;
while(n--) {
cin >> aux;
cin.get(c);
getline(cin, p);
tiempo[p] += aux;
}
vector<pair<lli, string>>v;
for(auto &x:tiempo) {
v.push_back({x.second, x.first});
}
sort(v.begin(), v.end(), cmp);
int cont = 0;
for(int i = v.size()-1; i >= 0 && cont < 3; i--) {
if(v[i].first >= 30 && cont < 3) {
cout << v[i].second << '\n';
cont++;
}
}
cout << "---\n";
cin >> n;
}
}