题解 | #合并表记录#
合并表记录
http://www.nowcoder.com/practice/de044e89123f4a7482bd2b214a685201
n = int(input())
dic = {}
# idea: 动态建构字典
for i in range(n):
line = input().split()
key = int(line[0])
value = int(line[1])
dic[key] = dic.get(key, 0) + value # 累积key所对应的value
for each in sorted(dic): # 最后的键值对按照升值排序
print(each, dic[each])