#P433. 练75.1奖学金【07NOIP普及组】
练75.1奖学金【07NOIP普及组】
Description
A primary school recently received a sponsorship and plans to use part of it to award scholarships to the top 5 students with the best academic performance. At the end of the semester, each student has scores in 3 subjects: Chinese, Math, and English. First, sort students by total score in descending order. If two students have the same total score, sort by Chinese score in descending order. If both total and Chinese scores are the same, the student with the smaller student number ranks higher. This ensures a unique ranking for each student.
Task: First, calculate the total score for each student based on the input scores for the 3 subjects, then sort according to the above rules, and finally output the student number and total score of the top five students in order. Note that each of the top 5 students receives a different scholarship, so you must strictly follow the sorting rules. For example, if the correct answer's first two lines are:
7 279
5 279
This means the two students with the highest total scores have student numbers 7 and 5, both with a total score of 279, but student 7 has a higher Chinese score. If your output is:
5 279
7 279
then it will be considered incorrect.
Input Format
The first line contains a positive integer , the number of students participating in the selection.
The next lines each contain 3 space-separated numbers, each between and . The -th line's 3 numbers represent the Chinese, Math, and English scores of the student with student number (student numbers are to , which is the line number minus 1).
All data is guaranteed to be valid; no need to check.
Output Format
There are 5 lines in total, each containing two positive integers separated by a space, representing the student number and total score of the top 5 students in order.
Sample
6
90 67 80
87 66 91
78 89 91
88 99 77
67 89 64
78 89 986 265
4 264
3 258
2 244
1 237