题解 | #合并表记录#
合并表记录
https://www.nowcoder.com/practice/de044e89123f4a7482bd2b214a685201
n = input() strList = [] strMap = {} for i in range(int(n)): strList.append(input()) for str in strList: key, value = str.split(" ")[0], str.split(" ")[1] if int(key) not in strMap: strMap[int(key)] = int(value) else: strMap[int(key)] += int(value) for kv in sorted(strMap): print(f"{kv} {strMap[kv]}")#一步步慢慢来#