#P8830. Dynamic Average Score Calculation

    ID: 21994 Type: Default 1000ms 256MiB

Dynamic Average Score Calculation

Dynamic Average Score Calculation

A contestant, Little A, participates in a variety show where n judges (3 ≤ n ≤ 106) award scores in the range [0, 100]. The judges reveal their scores sequentially. Starting from the third judge, immediately after the i-th judge gives a score, compute the average score of the contestant based on the first i scores after removing exactly one highest score and one lowest score. The average must be printed with exactly 2 decimal places.

For example, if the scores are: 10, 20, 30, 40, 50, then:

  • After 3 judges: scores = [10, 20, 30] → remove 10 and 30, average = 20.00
  • After 4 judges: scores = [10, 20, 30, 40] → remove 10 and 40, average = 25.00
  • After 5 judges: scores = [10, 20, 30, 40, 50] → remove 10 and 50, average = 30.00

inputFormat

The first line contains an integer n (3 ≤ n ≤ 10^6), the number of judges. The second line contains n space-separated integers representing the scores given by the judges in the order they were given.

outputFormat

For each judge from the third one to the n-th, output a line containing the calculated average score after removing one highest and one lowest score from the scores seen so far. The average should be printed with exactly 2 decimal places.

sample

3
10 50 40
40.00

</p>