题解 | #记票统计#

记票统计

https://www.nowcoder.com/practice/3350d379a5d44054b219de7af6708894

import sys
count1 = 0
active = 0
table1,table2 = {},[]
for line in sys.stdin:
    count1+=1
    if count1 == 1:
        num1=int(line.strip())
    elif count1 == 2:
        a2 = line.strip().split(" ")
        for i in a2:
            table2.append(i)
            table1[i] = 0
    elif count1 == 3:
        num2=int(line.strip())
    elif count1 == 4:
        a1 = line.strip().split(" ")
        for i in a1:
            if i in table1:
                active +=1
                table1[i] +=1
for i in table2:
    print(i,":",table1[i])
print("Invalid :",num2-active)
    

全部评论

相关推荐

点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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