#C11944. Final Grades Calculation
Final Grades Calculation
Final Grades Calculation
You are given the number of students and for each student three integers:
student_id
internal_grade
endterm_grade
The final grade for a student is defined as the integer average of the internal and endterm grades, i.e. \(\text{final_grade} = \frac{\text{internal_grade} + \text{endterm_grade}}{2}\) using floor division.
Your task is to calculate the final grade for each student and output the list of students sorted primarily in descending order of the final grade. In case of a tie (i.e. equal final grades), sort by student_id
in ascending order.
The input is provided via standard input and the output should be printed to standard output.
inputFormat
The first line contains an integer \(N\) representing the number of students. Each of the following \(N\) lines contains three space-separated integers: student_id
, internal_grade
, and endterm_grade
.
outputFormat
Output \(N\) lines. Each line contains two space-separated integers: student_id
and final_grade
, following the sorted order described above.
3
101 76 85
102 90 78
103 88 94
103 91
102 84
101 80
</p>