P1093 [NOIP 2007 Junior] Scholarship
Background
NOIP2007 普及组 T1
Description
An elementary school recently received sponsorship and plans to award scholarships to the top $5$ students with the best academic performance. At the end of the term, each student has scores in $3$ 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 $3$ 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 $5$ 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:
```plain
7 279
5 279
```
these two lines mean that the student IDs of the two students with the highest total scores are $7$ and $5$ in order. Both students have a total score of $279$ (the total score equals the sum of the scores in Chinese, Mathematics, and English), but the student with ID $7$ has a higher Chinese score.
If your first two lines of output are:
```plain
5 279
7 279
```
then it will be judged as wrong output and you will receive no score.
Input Format
There are $n+1$ lines.
- The first line contains a positive integer $n \le 300$, representing the number of students participating in the selection.
- Lines $2$ to $n+1$ each contain $3$ space-separated integers, each between $0$ and $100$ inclusive. On line $j$, the $3$ integers are the scores of the student with ID $j-1$ in this order: Chinese, Mathematics, English. Each student's ID is numbered from $1$ to $n$ according to the input order (exactly the line number minus $1$).
The given testdata are guaranteed to be valid; no need to validate.
Output Format
Output $5$ lines. Each line contains two space-separated positive integers, representing the student ID and the total score of the top $5$ students, in order.
Explanation/Hint
Translated by ChatGPT 5