题解 | #合并表记录#
合并表记录
http://www.nowcoder.com/practice/de044e89123f4a7482bd2b214a685201
dic = {} n = int(input()) while True: try: line = input() tmp = line.split() index = int(tmp[0]) value = int(tmp[1]) if index in dic: dic[index] += value else: dic[index] = value except: break for k, v in sorted(dic.items()): print(f'{k} {v}')