题解 | #合并表记录#

合并表记录

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

dict0 = {}
li0 = []
li1 = []
while True:
    try:
        lines = int(input())
        for i in range(lines):
            da = input()
            li = da.split(" ")
            n = int(li[0])
            v = li[1]
            if n not in li0:
                li0.append(n)
                dict0[n] = v
            else:
                t = dict0[n]
                dict0[n] = str(int(t) + int(v))
    except:
        break
for i in sorted(dict0.keys()):
    print(str(i) + " " + dict0[i])
全部评论

相关推荐

微风不断:兄弟,你把四旋翼都做出来了那个挺难的吧
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务