题解 | #合并表记录#
合并表记录
http://www.nowcoder.com/practice/de044e89123f4a7482bd2b214a685201
n = int(input().strip())
my_dict = {}
for i in range(n):
a, b = list(map(int, input().strip().split()))
if a not in my_dict:
my_dict[a] = b
else:
my_dict[a] = my_dict[a] + b
my_list = sorted(my_dict)//对key进行升序排序再输出,不然就报错了。
for item in my_list:
print(str(item) + ' ' + str(my_dict[item]))