题解 | #合并表记录#
合并表记录
https://www.nowcoder.com/practice/de044e89123f4a7482bd2b214a685201
num = int(input()) mylist = {} for i in range(num): key_value = input().split(' ') key = int(key_value[0]) value = int(key_value[1]) mylist[key] = mylist.get(key, 0) + value for i in sorted(mylist): print(str(i)+' '+str(mylist[i]))