题解 | 合并表记录

import sys

n = int(input())
temp = {}
for i in range(n):
    #获取并处理数据
    key,value = map(int,input().split(' '))
    #根据字典特性进行简单判断
    if key not in temp:
        temp[key] = value
    else:
        temp[key] += value

#键值对按照升值排序
for i in sorted(temp):
    print(i,temp[i])

全部评论

相关推荐

Twilight_m...:还是不够贴近现实,中关村那块60平房子200万怎么可能拿的下来,交个首付还差不多
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
07-21 13:38
8月实习会变多吗现在还没找到实习该怎么办...回复的hr好少
码农索隆:3-4月就要开始找,基本上6月份就发offer,7月初已经开始暑期实习了。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务