Canadian Computing Competition: 2012 Stage 1, Senior #3
You are gathering readings of acidity level in a very long river in
order to determine the health of the river. You have placed
If there are more than two readings that have the highest frequency, the difference computed should be the largest such absolute difference between two readings with this frequency. If there is only one reading with the largest frequency, but more than one reading with the second largest frequency, the difference computed should be the largest absolute difference between the most frequently occurring reading and any of the readings which occur with second-highest frequency.
Input Specification
The first line of input will be the integer
Output Specification
Output the positive integer value representing the absolute difference between the two most frequently occurring readings, subject to the tie-breaking rules outlined above.
Sample Input 1
5
1
1
1
4
3
Output for Sample Input 1
3
Sample Input 2
4
10
6
1
8
Output for Sample Input 2
9
Comments
If their are more than two numbers in the input with the same amount of occurrences, do I calculate the absolute difference using the two with the same number of occurrences, or do I calculate it with the second most frequent amount of occurrences?
If multiple numbers have the same amount of occurrences, I think you would calculate the absolute difference of the two numbers that will cause you to get the largest possible absolute value.