-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path2A Winner.cpp
62 lines (59 loc) · 1.38 KB
/
2A Winner.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
57
58
59
60
61
62
/*
author : MishkatIT
created : Monday 2023-08-07-21.42.02
*/
#include<bits/stdc++.h>
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define debug(_) cout << #_ << " is " << _ << '\n';
using namespace std;
using ll = long long;
using ld = long double;
const ll mod = 1e9 + 7;
const ll N = 1e5 + 10;
const ll inf = 1e9;
const ll linf = 1e18;
int main()
{
fio;
int n;
cin >> n;
map<string, int> mp;
map<int, vector<string>> track;
for (int i = 0; i < n; i++) {
string name;
cin >> name;
int score;
cin >> score;
mp[name] += score;
track[mp[name]].push_back(name);
for (int i = 0; i < mp[name]; i++) {
track[i].push_back(name);
}
}
// cout << '\n' << '\n';
// for (auto i: track) {
// cout << i.first << ' ';
// for (auto& x: i.second) {
// cout << x << ' ';
// }
// cout << '\n';
// }
int mx = 0;
for (auto& i: mp) {
mx = max(mx, i.second);
}
// debug(mx)
string ans = "";
for (auto it = track.rbegin(); it != track.rend(); it++) {
if(it -> first == mx) {
for(auto& x: it -> second) {
if(mp[x] == mx) {
ans = x;
break;
}
}
break;
}
}
cout << ans;
}