题解 | #合并表记录#
合并表记录
http://www.nowcoder.com/practice/de044e89123f4a7482bd2b214a685201
while True: try: n =int(input().strip()) except EOFError: break nums = {} for i in range(n): k,v = map(int,input().strip().split()) if nums.get(k): v = nums.get(k) + v nums.__setitem__(k, v) else: nums.__setitem__(k, v) min_k =min(nums.keys()) while True: print(min_k,nums.get(min_k)) nums.pop(min_k) if nums.keys(): min_k =min(nums.keys()) else: break