题解 | #合并表记录#
合并表记录
https://www.nowcoder.com/practice/de044e89123f4a7482bd2b214a685201
while True: try: n = int(input()) res = {} for i in range(n): a, b = map(int, input().split()) if a in res: res[a] = res[a] + b else: res[a] = b res1 = sorted(res.items(), key=lambda x: x[0]) for i, j in res1: print(f"{i} {j}") except: break
Python刷华为机考题 文章被收录于专栏
无聊刷刷!