题解 | #合并表记录#
合并表记录
https://www.nowcoder.com/practice/de044e89123f4a7482bd2b214a685201
import sys
if __name__=="__main__":
inputSlice=list(sys.stdin)
count_=int(inputSlice[0])
map={}
for i in range(count_):
thisItemSlice=inputSlice[i+1].split(" ")
key=thisItemSlice[0]
map[key]=map.get(key,0)+int(thisItemSlice[1])
items=sorted([item for item in map.items()],key=lambda item:int(item[0]))
for item in items:
print(item[0],item[1])
