#B3968. Student Score Ranking

    ID: 11625 Type: Default 1000ms 256MiB

Student Score Ranking

Student Score Ranking

There are \( n \) students, and each student has scores in three subjects: Chinese, Math, and English. Your task is to rank the students in descending order based on the following rules:

  • Compare the total score \( S = \text{Chinese} + \text{Math} + \text{English} \); the higher total score ranks higher.
  • If two students have the same total score, compare the sum of their Chinese and Math scores \( C+M \); the higher sum ranks higher.
  • If still tied, compare the maximum score between Chinese and Math \( \max(\text{Chinese}, \text{Math}) \); the higher maximum ranks higher.
  • If they are still equal after these comparisons, they are considered tied.

After determining the order, assign rankings as follows: if \( x \) students tie at a certain rank, all of them receive the same rank and the next available rank is increased by \( x \). For example, if three students tie for rank 1, the following student will have rank 4.

You are required to output the ranking for each student in the original input order.

inputFormat

The first line contains an integer \( n \) (the number of students). The following \( n \) lines each contain three space-separated integers representing the scores in Chinese, Math, and English respectively.

outputFormat

Output \( n \) lines, where each line contains the ranking of the corresponding student in the order they appeared in the input.

sample

4
80 90 100
90 80 100
100 70 90
100 80 90
2

2 4 1

</p>