题解 | #合并表记录#
合并表记录
https://www.nowcoder.com/practice/de044e89123f4a7482bd2b214a685201
a = int(input()) b = {} for i in range(a): key = input().split(" ") k = int(key[0]) v = int(key[1]) try: b[k] += v except KeyError: b[k] = v # 按键升序排序并输出 for k in sorted(b): print(k, b[k], end="\n")