题解 | #合并表记录#
合并表记录
https://www.nowcoder.com/practice/de044e89123f4a7482bd2b214a685201
import sys input_data = sys.stdin.read().split() n = int(input_data[0]) D = {} for i in range(1,n*2,2): index = int(input_data[i]) value = int(input_data[i+1]) if index in D.keys(): D[index] = D[index] + value else: D[index] = value for index in sorted(D.keys()): print(index,D[index])