题解 | #合并表记录#
合并表记录
http://www.nowcoder.com/practice/de044e89123f4a7482bd2b214a685201
num = int(input()) dic = {} for _ in range(num): k,v = [int(i) for i in input().split()] if k in dic: dic[k] += v else: dic[k] = v dic = dict(sorted(dic.items(), key=lambda x:x[0])) for k,v in dic.items(): print(k,v)