#P1093. [NOIP 2007 普及组] 奖学金
[NOIP 2007 普及组] 奖学金
Description
An elementary school recently received sponsorship and plans to award scholarships to the top students with the best academic performance. At the end of the term, each student has scores in 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 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 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 and in order. Both students have a total score of (the total score equals the sum of the scores in Chinese, Mathematics, and English), but the student with ID 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 lines.
- The first line contains a positive integer , representing the number of students participating in the selection.
- Lines to each contain space-separated integers, each between and inclusive. On line , the integers are the scores of the student with ID in this order: Chinese, Mathematics, English. Each student's ID is numbered from to according to the input order (exactly the line number minus ).
The given testdata are guaranteed to be valid; no need to validate.
Output Format
Output lines. Each line contains two space-separated positive integers, representing the student ID and the total score of the top 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
京公网安备 11011102002149号