题解 | #记票统计#
记票统计
https://www.nowcoder.com/practice/3350d379a5d44054b219de7af6708894
n = int(input()) # 候选的人数 4
ls = input().split() #候选人的名字 A B C D
m = int(input()) # 投票的人数 8
tp = input().split() # 票数 # A D E CF A GG A B
c = 0
for i in ls:
c += tp.count(i)
print(i + ' : ' + str(tp.count(i))) # 注意 str(tp.count(i))
print('Invalid : ' + str(m - c))

查看7道真题和解析