题解 | #合并表记录#

合并表记录

https://www.nowcoder.com/practice/de044e89123f4a7482bd2b214a685201

while True:
    try:
        n = int(input())
        record = {}
        for i in range(n):
            adict = list(map(int, input().split()))
            if adict[0] not in record.keys():
                record[adict[0]] = adict[1]
            else:
                record[adict[0]] += adict[1]
        keys = list(record.keys())
        keys.sort()
        for key in keys:
            print(key, end=' ')
            print(record[key])
    except:
        break

全部评论

相关推荐

叁六玖:你看,最后不是让你加油,就是鼓励你,还祝福你求职顺利。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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