#include <iostream>
#include <cstring>
#include <string>
using namespace std;
const int MAX_SIZE = 10000;
int workerHours[MAX_SIZE + 1];
int main() {
int numberOfLines, maxHours = -1, workerWithMaxHours = -1;
cin >> numberOfLines;
cin.ignore();
for (int i = 0; i < numberOfLines; ++i) {
string line;
getline(cin, line);
int workerId, hours;
sscanf(line.c_str(), "Muncitorul %d a muncit %d ore", &workerId, &hours);
workerHours[workerId] += hours;
if (workerHours[workerId] > maxHours) {
maxHours = workerHours[workerId];
workerWithMaxHours = workerId;
} else if (workerHours[workerId] == maxHours && workerId < workerWithMaxHours) {
workerWithMaxHours = workerId;
}
}
cout << workerWithMaxHours;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Y3N0cmluZz4KI2luY2x1ZGUgPHN0cmluZz4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmNvbnN0IGludCBNQVhfU0laRSA9IDEwMDAwOwppbnQgd29ya2VySG91cnNbTUFYX1NJWkUgKyAxXTsKCmludCBtYWluKCkgewogICAgaW50IG51bWJlck9mTGluZXMsIG1heEhvdXJzID0gLTEsIHdvcmtlcldpdGhNYXhIb3VycyA9IC0xOwogICAgY2luID4+IG51bWJlck9mTGluZXM7CiAgICBjaW4uaWdub3JlKCk7CiAgICBmb3IgKGludCBpID0gMDsgaSA8IG51bWJlck9mTGluZXM7ICsraSkgewogICAgICAgIHN0cmluZyBsaW5lOwogICAgICAgIGdldGxpbmUoY2luLCBsaW5lKTsKICAgICAgICBpbnQgd29ya2VySWQsIGhvdXJzOwogICAgICAgIHNzY2FuZihsaW5lLmNfc3RyKCksICJNdW5jaXRvcnVsICVkIGEgbXVuY2l0ICVkIG9yZSIsICZ3b3JrZXJJZCwgJmhvdXJzKTsKICAgICAgICB3b3JrZXJIb3Vyc1t3b3JrZXJJZF0gKz0gaG91cnM7CiAgICAgICAgaWYgKHdvcmtlckhvdXJzW3dvcmtlcklkXSA+IG1heEhvdXJzKSB7CiAgICAgICAgICAgIG1heEhvdXJzID0gd29ya2VySG91cnNbd29ya2VySWRdOwogICAgICAgICAgICB3b3JrZXJXaXRoTWF4SG91cnMgPSB3b3JrZXJJZDsKICAgICAgICB9IGVsc2UgaWYgKHdvcmtlckhvdXJzW3dvcmtlcklkXSA9PSBtYXhIb3VycyAmJiB3b3JrZXJJZCA8IHdvcmtlcldpdGhNYXhIb3VycykgewogICAgICAgICAgICB3b3JrZXJXaXRoTWF4SG91cnMgPSB3b3JrZXJJZDsKICAgICAgICB9CiAgICB9CiAgICBjb3V0IDw8IHdvcmtlcldpdGhNYXhIb3VyczsKICAgIHJldHVybiAwOwp9
NQpNdW5jaXRvcnVsIDEgYSBtdW5jaXQgMTAgb3JlCk11bmNpdG9ydWwgMjMgYSBtdW5jaXQgNSBvcmUKTXVuY2l0b3J1bCAzIGEgbXVuY2l0IDMgb3JlCk11bmNpdG9ydWwgMjMgYSBtdW5jaXQgMTEgb3JlCk11bmNpdG9ydWwgMSBhIG11bmNpdCAyIG9yZQ==
5
Muncitorul 1 a muncit 10 ore
Muncitorul 23 a muncit 5 ore
Muncitorul 3 a muncit 3 ore
Muncitorul 23 a muncit 11 ore
Muncitorul 1 a muncit 2 ore