#P5759. [NOI1997] 竞赛排名

[NOI1997] 竞赛排名

Description

A city organized an all-round science and technology contest for middle school students. Each participant takes part in eight contests: Mathematics, Physics, Chemistry, Astronomy, Geography, Biology, Computer Science, and English. In the end, the overall ranking is determined based on the combined results of these eight contests.

The contestant IDs are 1,2,,N1,2,\dots,N (NN is the total number of participants). Let xi,jx_{i, j} (1iN,1j81 \le i \le N, 1 \le j \le 8) denote the score of contestant ii in contest jj. Other indicators are defined as follows:

  • The average score of contest jj (1j81 \le j \le 8): avgj=1Ni=1Nxi,javg_j = \frac{1}{N} \sum_{i=1}^N x_{i, j}
  • The total score of contestant ii (1iN1 \le i \le N): sumxi=j=18xi,jsumx_i = \sum_{j=1}^8 x_{i, j}
  • The positional score of contestant ii (1iN1 \le i \le N) in contest jj (1j81 \le j \le 8):
$$y_{i, j}= \begin{cases} 0 & \left(\sum_{i = 1} ^ N |x_{i, j} - avg_j| = 0\right) \\ \frac{x_{i, j} - avg_j}{\frac{1}{N} \sum_{i = 1} ^ N |x_{i ,j} - agv_j|} & \left(\sum_{i = 1} ^ N |x_{i, j} - avg_j| \ne 0\right)\end{cases}$$
  • The total positional score of contestant ii (1iN1 \le i \le N): $sumy_i = \sum_{j=1}^3 y_{i, j} + 0.8 \sum_{j=4}^8 y_{i, j}$

The ranking rules are as follows:

  1. Contestants with higher total positional scores rank earlier.
  2. If two or more contestants have the same total positional score, the one with the higher total score ranks earlier.
  3. If two or more contestants have the same total positional score and the same total score, the one with the smaller ID ranks earlier.

Please write a program for the contest committee to compute the overall ranking for this all-round contest.

Input Format

The first line contains the total number of participants NN. From the second line to the NN-th line, the scores of contestants with IDs from 11 to NN are given in order. Each line contains 88 integers between 00 and 100100, representing the contestant’s scores in the 8 contests. Adjacent numbers on the same line are separated by one space.

Output Format

Output NN lines. From line 1 to line NN, output the ID of the contestant ranked 1st, the ID of the contestant ranked 2nd, \dots, and the ID of the contestant ranked NN-th.

3
72 82 73 68 95 86 82 90
72 90 50 60 80 70 65 80
72 82 73 68 95 86 82 90

1
3
2

Hint

Constraints

For all testdata, 1N10001 \le N \le 1000.

Translated by ChatGPT 5