#include <algorithm>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <string>
#include <vector>
#include <map>
using namespace std;
int main()
{
int max = -1, max_t = 10000;
string max_n;
map<string, pair<int, int>>arr;
int n;
cin >> n;
for(int i = 0; i < n; i++){
string name;
int score;
cin >> name >> score;
arr[name] = make_pair(arr[name].first + score, i);
}
for (auto it = arr.begin(); it != arr.end(); it++)
{
int num = it->second.first;
int turn = it->second.second;
string name = it->first;
if (max < num) {
max = num;
max_n = name;
max_t = turn;
}
else if (max == num) {
if (max_t > turn) {
max_n = name;
max_t = turn;
}
}
}
cout << max_n << endl;
}
为甚么case6过不去啊