#P11950. Diving Competition Ranking

    ID: 14059 Type: Default 1000ms 256MiB

Diving Competition Ranking

Diving Competition Ranking

In a diving competition, there are (n) divers and (m) judges. After each diver performs, every judge awards a score. The final score for a diver is computed by discarding one occurrence of the maximum score and one occurrence of the minimum score (even if there are multiple occurrences) and then taking the average of the remaining scores. The divers are then ranked in descending order of their final score. In the case of a tie, the diver with the smaller index (i.e. lower number) is ranked higher. Given the scores awarded by the judges for each diver, compute the ranking order; that is, for (1 \leq i \leq n), determine the index of the diver who is ranked (i)th.

The final scores are calculated as follows: [ score = \frac{\text{sum of all scores} - \max(\text{scores}) - \min(\text{scores})}{m-2} ]

If two divers have the same final score, the diver with the smaller index (number) is considered to have a better rank.

inputFormat

The first line contains two integers (n) and (m) representing the number of divers and the number of judges respectively. The following (n) lines contain (m) space-separated integers each; the (j)th integer on the (i)th line is the score given by the (j)th judge to the (i)th diver.

outputFormat

Output a single line containing (n) space-separated integers. The (i)th integer is the index of the diver who is ranked (i)th.

sample

3 5
5 6 7 8 9
6 7 8 9 10
9 8 7 6 5
2 1 3