atcoder#AGC041B. [AGC041B] Voting Judges
[AGC041B] Voting Judges
Score : points
Problem Statement
problems are proposed for an upcoming contest. Problem has an initial integer score of points.
judges are about to vote for problems they like. Each judge will choose exactly problems, independently from the other judges, and increase the score of each chosen problem by .
After all judges cast their vote, the problems will be sorted in non-increasing order of score, and the first problems will be chosen for the problemset. Problems with the same score can be ordered arbitrarily, this order is decided by the chief judge.
How many problems out of the given have a chance to be chosen for the problemset?
Constraints
Input
Input is given from Standard Input in the following format:
Output
Print the number of problems that have a chance to be chosen for the problemset.
6 1 2 2
2 1 1 3 0 2
5
If the only judge votes for problems and , the scores will be . The problemset will consist of problem and one of problems , , or .
If the only judge votes for problems and , the scores will be . The problemset will consist of problem and one of problems , , or .
Thus, problems , , , , and have a chance to be chosen for the problemset. On the contrary, there is no way for problem to be chosen.
6 1 5 2
2 1 1 3 0 2
3
Only problems , , and have a chance to be chosen.
10 4 8 5
7 2 3 6 1 6 5 4 6 5
8