题解 | #记票统计#

记票统计

https://www.nowcoder.com/practice/3350d379a5d44054b219de7af6708894?tpId=37&tqId=21317&rp=1&ru=/exam/oj/ta&qru=/exam/oj/ta&sourceUrl=%2Fexam%2Foj%2Fta%3FtpId%3D37&difficulty=undefined&judgeStatus=undefined&tags=&title=94

from collections import defaultdict

n = int(input())
names = input().split(" ")

m = int(input())
votes = input().split(" ")

d = dict()

for name in names:
    d[name] = 0
d["Invalid"] = 0

for vote in votes:
    if vote not in d:
        d["Invalid"] += 1
    else:
        d[vote] += 1

for name in names:
    print("{} : {}".format(name, d[name]))
print("Invalid : {}".format(d["Invalid"]))

全部评论

相关推荐

评论
1
收藏
分享

创作者周榜

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