题解 | #合并表记录#
合并表记录
https://www.nowcoder.com/practice/de044e89123f4a7482bd2b214a685201
from collections import defaultdict n = int(input()) d = defaultdict(int) for i in range(n): idx, val = map(int, input().split()) d[idx] += val for key in sorted(d): print("{} {}".format(key, d[key]))