合并表记录(Python3解答)
合并表记录
http://www.nowcoder.com/questionTerminal/de044e89123f4a7482bd2b214a685201
while True: try: a=int(input()) dic = {} for i in range(a): key, val = input().split() key = int(key) val = int(val) if key in dic: dic[key] += val else: dic[key] = val for i in sorted(dic.keys()): print(str(i)+" "+str(dic[i])) except: break