题解 | #合并表记录#
合并表记录
https://www.nowcoder.com/practice/de044e89123f4a7482bd2b214a685201
while True: try: n = int(input()) indexKey = {} for i in range(n): a = input().split() if a[0] in indexKey: indexKey[a[0]].append(int(a[1])) else: indexKey[a[0]] = [] indexKey[a[0]].append(int(a[1])) for i in range(len(indexKey)): minindex = min(list(map(int,indexKey.keys()))) valsum = sum(indexKey.pop(str(minindex))) print('%d %d'%(minindex,valsum)) except: break