题解 | #合并表记录#
合并表记录
https://www.nowcoder.com/practice/de044e89123f4a7482bd2b214a685201
n = int(input()) map = {} for i in range(n): k, v = (int(x) for x in input().split(" ")) if k in map: map[k] += v else: map[k] = v #按key排序 map = sorted(map.items()) for k, v in map: print(k, v)