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