#P1093. [NOIP 2007 普及组] 奖学金

[NOIP 2007 普及组] 奖学金

Description

An elementary school recently received sponsorship and plans to award scholarships to the top 55 students with the best academic performance. At the end of the term, each student has scores in 33 subjects: Chinese, Mathematics, and English. First, sort by total score in descending order. If two students have the same total score, sort by Chinese score in descending order. If both the total score and the Chinese score are the same, the student with the smaller student ID comes first. In this way, each student's ranking is uniquely determined.

Task: First compute the total score from the 33 subject scores in the input, then sort according to the rules above, and finally output the student IDs and total scores of the top five students in rank order.

Note that among the top 55 students, each person's scholarship is different, so you must strictly follow the rules above for sorting. For example, in a correct answer, if the first two lines of output data (each line outputs two numbers: student ID and total score) are:

7 279  
5 279

these two lines mean that the student IDs of the two students with the highest total scores are 77 and 55 in order. Both students have a total score of 279279 (the total score equals the sum of the scores in Chinese, Mathematics, and English), but the student with ID 77 has a higher Chinese score.

If your first two lines of output are:

5 279  
7 279

then it will be judged as wrong output and you will receive no score.

Input Format

There are n+1n+1 lines.

  • The first line contains a positive integer n300n \le 300, representing the number of students participating in the selection.
  • Lines 22 to n+1n+1 each contain 33 space-separated integers, each between 00 and 100100 inclusive. On line jj, the 33 integers are the scores of the student with ID j1j-1 in this order: Chinese, Mathematics, English. Each student's ID is numbered from 11 to nn according to the input order (exactly the line number minus 11).

The given testdata are guaranteed to be valid; no need to validate.

Output Format

Output 55 lines. Each line contains two space-separated positive integers, representing the student ID and the total score of the top 55 students, in order.

6
90 67 80
87 66 91
78 89 91
88 99 77
67 89 64
78 89 98

6 265
4 264
3 258
2 244
1 237


8
80 89 89
88 98 78
90 67 80
87 66 91
78 89 91
88 99 77
67 89 64
78 89 98
8 265
2 264
6 264
1 258
5 258

Hint

Translated by ChatGPT 5