#P1093. Scholarship Distribution Ranking

    ID: 12977 Type: Default 1000ms 256MiB

Scholarship Distribution Ranking

Scholarship Distribution Ranking

A primary school has recently received a sponsorship and has decided to award scholarships to the top 5 students based on their academic performance. Each student has obtained scores in three subjects: Chinese, Mathematics, and English. After the final exams, every student's total score is computed as \(\text{total} = \text{Chinese} + \text{Mathematics} + \text{English}\). The students are then ranked by the following criteria:

  1. Descending order of the total score.
  2. If two students have the same total score, the one with the higher Chinese score ranks higher.
  3. If both the total score and the Chinese score are identical, the student with the smaller ID number ranks higher.

Your task is to calculate the total score for each student, sort them according to the rules described above, and then output the ID and total score of the top five students in order. Note: In the top five, each student’s scholarship is unique, so the ranking must strictly follow the given rules.

inputFormat

The first line of input contains an integer n (n ≥ 5) indicating the number of students. This is followed by n lines, each line containing three integers representing the scores in Chinese, Mathematics, and English respectively. The students are assigned IDs from 1 to n in the order in which they appear in the input.

outputFormat

Output exactly 5 lines. Each line should consist of two integers separated by a space: the student's ID and their total score. The ranking must strictly adhere to the rules described above.

sample

6
85 90 95
90 90 90
95 85 95
80 90 100
95 80 90
90 95 80
3 275

2 270 1 270 4 270 5 265

</p>