题解 | #合并表记录#
合并表记录
https://www.nowcoder.com/practice/de044e89123f4a7482bd2b214a685201
n = int(input())
index = []
value = []
dic = {}
for i in range(n):
arr = input().split()
index = int(arr[0])
value = int(arr[1])
if index in dic:
dic[index] += value
else:
dic[index] = value
for k, v in sorted(dic.items()):
print(f'{k} {v}')
查看4道真题和解析

