题解 | #记票统计#
记票统计
https://www.nowcoder.com/practice/3350d379a5d44054b219de7af6708894
import sys candidates_number = input() candidates_name = input().split() voters_number = input() voters = input().split() e = {} invalid = 0 for i in voters: if i in candidates_name: if i not in e.keys(): e[i] = 1 else: e[i] += 1 else: invalid += 1 for i in candidates_name: if i not in voters: e[i] = 0 print(f"{i} : {e[i]}") print(f"Invalid : {invalid}")