The problem is from codeforces http://codeforces.com/problemset/problem/2/A

To solve this problem, you will probably need to know the dictionary. In Python, the dictionary structure can be declared using notation {}. The dictionary has two important functions: keys() and values() which return the results as a set i.e. []. For example, the following Python code shows the basics to use dictionary.
#helloacm.com
# declare an empty dictionary
d = {}
# add an item
d['key1'] = 1
# add a set as another item
d['key2'] = [1, 2, 3, 4]
# {'key2': [1, 2, 3, 4], 'key1': 1}
print d
# ['key2', 'key1']
print d.keys()
# [[1, 2, 3, 4], 1]
print d.values()
The solution to this problem is presented as follows. A dictionary is defined to hold the total score while a set is used to kept scores step by step. Print the name of the player if its score is the maximum and his/her name appears the first.
#!/usr/bin/env python
#helloacm.com
n = int(raw_input())
a = [raw_input().split(' ') for x in range(0, n)]
r = {}
b = []
for i in range(0, n):
x, y = a[i]
y = int(y)
if x in r.keys():
r[x] += y
else:
r[x] = y
b.append((x, r[x]))
mx = max(r.values())
for x, p in b:
if p >= mx and r[x] == mx:
print x
break
–EOF (The Ultimate Computing & Technology Blog) —
289 wordsLast Post: How to Display Your Email Address As Image?
Next Post: Codeforces: C. Letter