题解 | 合并表记录
合并表记录
https://www.nowcoder.com/practice/de044e89123f4a7482bd2b214a685201
n = int(input())
records = {}
for _ in range(n):
x, y = map(int, input().split())
if x in records:
records[x] += y
else:
records[x] = y
for x in sorted(records.keys()):
print(x, records[x])

查看5道真题和解析