NOI '97 P1 - Competition Ranking

View as PDF

Submit solution

Points: 7
Time limit: 0.3s
Memory limit: 16M

Problem type
National Olympiad in Informatics, China, 1997

A city organized an all-around high school science Olympiad where N competitors (with ID's from 1 to N) each participate in 8 competitions in the subjects of mathematics, physics, chemistry, astronomy, geography, biology, informatics, and linguistics. In the end, scores are taken from all of these fields to produce an overall ranking of the competitors.

Let xi,j denote the rank of competitor i in the j-th competition (1iN,1j8).

  • The average score of the j-th competition is avgj=1Ni=1Nxi,j, (1j8).
  • The overall score of competitor i is sumxi=j=18xi,j, (1iN).
  • The rank of competitor i in the j-th competition is: yi,j={0(i=1N|xi,javgj|=0)xi,javgj1Ni=1N|xi,javgj|(i=1N|xi,javgj|0)
  • The overall position score for competitor i is sumyi=k=13yi,k+0.8k=48yi,k, (1iN).

The rules for ranking are as follows:

  1. Competitors with higher overall position scores are ranked higher.
  2. If two or more competitors have the same overall position score, then the competitor(s) with a higher overall score is ranked higher.
  3. If two or more competitors have the same overall position score and the overall score, then the competitor(s) with the smaller ID is ranked higher.

Please write a program for the organizers to compute the rankings of competitors.

Input Specification

The first line of input contains the integer N (1N1000). The following N lines will each contain 8 space-separated integers xi,1,xi,2,,xi,8, each between 0 and 100, representing the scores of each competitor in the 8 competitions.

Output Specification

The output should contain N lines, where line i contains the ID of the competitor with rank i (for 1iN).

Sample Input

Copy
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

Sample Output

Copy
1
3
2

Problem translated to English by Alex.


Comments

There are no comments at the moment.