题解 | #合并表记录#
合并表记录
https://www.nowcoder.com/practice/de044e89123f4a7482bd2b214a685201
n = int(input()) # 输入键值对的个数 dic = {} # 创建一个空字典 for i in range(0,n): key,value = map(int,input().split()) dic[key] = dic.get(key,0) + value # 累积key所对应的value for each in sorted(dic): print(each,dic[each])