#P4086. Maximized Grading Average After Discarding Lowest Score
Maximized Grading Average After Discarding Lowest Score
Maximized Grading Average After Discarding Lowest Score
In this problem, you are given a homework assignment with \( N \) questions, where \( 3 \leq N \leq 100000 \). Each question is graded with an integer score in the range 0 to 10000. Your teacher plans to compute your final grade by discarding the question on which you received the lowest score and then averaging the remaining scores.
Unfortunately, your pet cow Bessie has eaten your answers to the first \( K \) questions. The teacher agrees to grade the remaining part of the assignment in the same manner: remove one question with the lowest score (if there are ties, remove any one of them) from the remaining \( N-K \) questions, and the final grade is the average of the other scores.
Your task is to output all values of \( K \) (with \( 1 \leq K \leq N-2 \)) that yield the maximum possible final average. The answer should be sorted in increasing order.
Grading Computation:
For a given \( K \), let the remaining scores be \( a_{K+1}, a_{K+2}, \dots, a_{N} \). Let \( S(K) \) be their sum and \( m(K) \) be the minimum score among them. The final average for that \( K \) is computed as:
[ \text{Average}(K) = \frac{S(K) - m(K)}{N-K-1} ]
Print all the \( K \) for which this average is maximized.
inputFormat
The first line contains a single integer \( N \) (the total number of questions). The second line contains \( N \) space-separated integers representing the scores of the questions.
outputFormat
Output all valid values of \( K \) (separated by a single space) that yield the maximum possible final average after grading the remaining questions.
sample
5
3 1 9 2 7
2