题解 | #合并表记录#
合并表记录
http://www.nowcoder.com/practice/de044e89123f4a7482bd2b214a685201
dict0 = {}
li0 = []
li1 = []
while True:
try:
lines = int(input())
for i in range(lines):
da = input()
li = da.split(" ")
n = int(li[0])
v = li[1]
if n not in li0:
li0.append(n)
dict0[n] = v
else:
t = dict0[n]
dict0[n] = str(int(t) + int(v))
except:
break
for i in sorted(dict0.keys()):
print(str(i) + " " + dict0[i])