#t262. 奖学金
奖学金
Scholarships
Problem Background
NOIP 2007, Popularization Group, Problem T1.
Problem Description
A primary school has recently received a sponsorship and plans to use part of it 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 from highest to lowest. If two students have the same total score, sort by Chinese score from highest to lowest. If both the total score and the Chinese score are equal, the student with the smaller student ID ranks first. In this way each student's rank is uniquely determined.
Your task: first compute the total score from the subjects, then sort according to the rules above, and finally output the student ID and total score of the top students in rank order.
Note that among the top students, each one's scholarship is different, so you must sort strictly by the rules above. For example, in a correct answer, if the first two output lines (each line has two numbers: student ID and total score) are:
7 279
5 279
their meaning is: the two students with the highest total scores have IDs and in that order. Both have a total score of (the sum of Chinese, Mathematics, and English), but the student with ID has a higher Chinese score.
If your output for the top two is:
5 279
7 279
it will be treated as an output error and scored zero.
Input Format
There are lines in total.
The first line is a positive integer , the number of students participating in the selection.
Lines through : each line has space-separated numbers, each between and . The numbers in line are respectively the Chinese, Mathematics, and English scores of the student whose ID is . Each student is numbered in input order (exactly the line number minus ).
The given data is guaranteed to be correct; no validation is needed.
Output Format
Output lines in total. Each line contains two space-separated positive integers: the student ID and total score of one of the top students, in rank order.
Sample Input
6
90 67 80
87 66 91
78 89 91
88 99 77
67 89 64
78 89 98
Sample Output
6 265
4 264
3 258
2 244
1 237
Sample Input 2
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
Sample Output 2
8 265
2 264
6 264
1 258
5 258