题解 | #合并表记录#
合并表记录
https://www.nowcoder.com/practice/de044e89123f4a7482bd2b214a685201
n = int(input()) d ={} for i in range(n): index,value = input().split() d[index] = int(d.get(index,0)) + int(value) # 字典排序 for key,value in sorted(d.items(),key=lambda x :int(x[0])): print(key,value)