#abc329d. D - Election Quick Report
D - Election Quick Report
Score : points
问题描述
存在一场选举,从编号为 的 名候选人中选出一名获胜者,目前已经投出了 票。
每张选票都恰好投给了一名候选人,其中第 张选票投给了候选人 。
投票将按照从第一票到最后一票的顺序进行计数,并且在每次计票后,都会更新并显示当前的获胜者。
在已统计的所有选票中,获得最多票数的候选人即为获胜者。如果有多个候选人得票最多,则编号最小的候选人为获胜者。
对于每个 ,请确定仅计算前 张选票时的获胜者。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
There is an election to choose one winner from candidates with candidate numbers , and there have been votes cast.
Each vote is for exactly one candidate, with the -th vote being for candidate .
The votes will be counted in order from first to last, and after each vote is counted, the current winner will be updated and displayed.
The candidate with the most votes among those counted is the winner. If there are multiple candidates with the most votes, the one with the smallest candidate number is the winner.
For each , determine the winner when counting only the first votes.
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Print lines.
The -th line should contain the winner's candidate number when counting only the first votes.
Sample Input 1
3 7
1 2 2 3 1 3 3
Sample Output 1
1
1
2
2
1
1
3
Let denote the number of votes for candidate .
- After the first vote is counted, , so the winner is .
- After the second vote is counted, , so the winner is .
- After the third vote is counted, , so the winner is .
- After the fourth vote is counted, , so the winner is .
- After the fifth vote is counted, , so the winner is .
- After the sixth vote is counted, , so the winner is .
- After the seventh vote is counted, , so the winner is .
Sample Input 2
100 5
100 90 80 70 60
Sample Output 2
100
90
80
70
60
Sample Input 3
9 8
8 8 2 2 8 8 2 2
Sample Output 3
8
8
8
2
8
8
8
2
update @ 2024/3/10 01:54:15