题解 | #记票统计#

记票统计

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

try:
    n=int(input())
    names=input().split()
    m=int(input())
    votes=input().split()
    res={}
    for k in names:
        res[k]=0
    res['Invalid']=0
    for v in votes:
        v='Invalid' if v not in names else v
        res[v]+=1
    for k,v in res.items():
        print(k,':',v)
except Exception as e:
    print(e)

全部评论

相关推荐

09-09 14:40
门头沟学院 Java
投递网易等公司10个岗位
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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