题解 | #合并表记录#
合并表记录
https://www.nowcoder.com/practice/de044e89123f4a7482bd2b214a685201
#究极体菜鸟解法
n=int(input())
listall=[]list0=list(map(int,input().split()))
listall.append(list0)
listi=[]
for i in listall:
listi.append(i[0])
for i in range(n-1):
listnew=list(map(int,input().split()))
try:
id=listi.index(listnew[0])
listall[id][1]+=listnew[1]
except:
listall.append(listnew)
listall.sort(key=lambda x: x[0])
listi=[]
for i in listall:
listi.append(i[0])
listall.sort(key=lambda x: x[0])
for i in listall:
print("%d %d" %(i[0],i[1]))
#华为od#