题解 | #合并表记录#
合并表记录
http://www.nowcoder.com/practice/de044e89123f4a7482bd2b214a685201
python 解法
while True:
try:
n = int(input())
res = {}
for i in range(n):
index, value = map(int,input().split())
if index in res:
res[index] += value
else:
res[index] = value
for key in sorted(res):
print('{} {}'.format(key,res[key]))
except:
break