题解 | #记票统计#

记票统计

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

n = input().strip()
candidate = input().strip().split()
m = input().strip()
ticket = input().strip().split()
summary = {}

for t in ticket:
    if t not in candidate:
        summary["Invalid"] = summary.get("Invalid", 0) + 1
    else:
        summary[t] = summary.get(t, 0) + 1

for c in candidate:
    print(f'{c} : {summary.get(c, 0)}')


print("Invalid", ":", summary.get('Invalid', 0))

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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