#P4263. Vote Count
Vote Count
Vote Count
Captain Wang organized a voting contest called "My Favourite Problem" to review the recent problem-setting work. Each problem is assigned a positive integer identifier. There are n contestants and each contestant votes exactly once for one problem. The vote of the i-th contestant is denoted by \(a_i\). Your task is to count the votes received by each problem and then identify the problems that have received the maximum number of votes. You should output the number of such problems and their identifiers in ascending order.
Exception: If all the voted problems have the same number of votes, then the contest is considered unsuccessful and you should output -1.
inputFormat
The first line contains a positive integer \(n\) representing the number of contestants.
The second line contains \(n\) positive integers \(a_1, a_2, \dots, a_n\) indicating the voted problem identifiers.
outputFormat
If all the problems that received votes have the same number of votes, output -1
.
Otherwise, output two lines: the first line is the count of problems with the maximum number of votes, and the second line contains the sorted identifiers of those problems in ascending order, separated by a space.
sample
5
1 2 2 3 2
1
2
</p>