#P5759. Multidisciplinary Science Competition Ranking

    ID: 18987 Type: Default 1000ms 256MiB

Multidisciplinary Science Competition Ranking

Multidisciplinary Science Competition Ranking

A city has organized a comprehensive science competition for middle school students. Each contestant participates in eight events: Mathematics, Physics, Chemistry, Astronomy, Geography, Biology, Computer Science, and English. The final overall ranking is determined based on the contestants' performances across all eight competitions.

Contestants are numbered: \(1,2,\dots,N\) where \(N\) is the total number of participants. Let \(x_{i,j}\) (for \(1 \le i \le N\) and \(1 \le j \le 8\)) denote the score of contestant \(i\) in competition \(j\). The following definitions are used:

  • For the \(j\)th competition, the average score is defined as \[ \text{avg}_j = \frac{1}{N}\sum_{i=1}^{N} x_{i,j}. \]
  • The total score of contestant \(i\) is \[ \text{sumx}_i = \sum_{j=1}^{8} x_{i,j}. \]
  • The position score for contestant \(i\) in competition \(j\) is defined by \[ y_{i,j}= \begin{cases} 0, & \text{if } \sum_{i=1}^{N} |x_{i,j}-\text{avg}_j| = 0, \\[6pt] \frac{x_{i,j}-\text{avg}_j}{\frac{1}{N}\sum_{i=1}^{N}|x_{i,j}-\text{avg}_j|}, & \text{otherwise.} \end{cases} \]
  • The total position score for contestant \(i\) is \[ \text{sumy}_i = \sum_{j=1}^{3} y_{i,j} + 0.8 \sum_{j=4}^{8} y_{i,j}. \]

The overall ranking is determined by the following rules:

  1. Contestants with a higher total position score \(\text{sumy}_i\) are ranked higher.
  2. If two or more contestants have the same total position score, the one with a higher total score \(\text{sumx}_i\) is ranked higher.
  3. If both the total position score and total score are the same, the contestant with the smaller number (i.e. earlier id) is ranked higher.

Your task is to write a program that computes and prints the overall ranking of the contestants. The input consists of \(N\) followed by \(N\) lines, each containing eight integers representing the contestant's scores. The output should list the contestant numbers in the order of their final ranking, with one number per line.

inputFormat

The first line contains an integer \(N\) (the number of contestants).

Each of the next \(N\) lines contains 8 space-separated integers, representing the scores for the eight competitions for a contestant.

outputFormat

Output the contestant numbers in separate lines according to their final ranking (from highest rank to lowest rank).

sample

3
90 80 70 60 50 40 30 20
80 90 60 70 40 50 20 30
70 60 80 50 30 20 40 90
1

2 3

</p>