#K39467. Student Grade Sorting

    ID: 26427 Type: Default 1000ms 256MiB

Student Grade Sorting

Student Grade Sorting

You are given a list of student records. Each record contains a student's name followed by three integer scores. Your task is to sort the student names in ascending order based on their average score. In case of a tie (i.e., two or more students having the same average score), the students should retain their original order as given in the input.

Note: The average score is calculated as \(\frac{s_1+s_2+s_3}{3}\) where \(s_1, s_2, s_3\) are the three scores.

Input Format:
The first line contains an integer \(n\) representing the number of students. Each of the following \(n\) lines contains a student's name and three space-separated integer scores.

Output Format:
Print the names of the students on separate lines in the order determined by the sorting criteria above.

inputFormat

The input starts with an integer \(n\) denoting the number of students. Following this, there are \(n\) lines, each containing a student’s name and three integer scores separated by spaces.

outputFormat

Output the names of the students on separate lines sorted in ascending order of their average score. If two or more students have the same average score, their relative order in the input should be preserved.

## sample
5
Alice 80 90 100
Bob 70 80 90
Charlie 90 90 90
David 60 70 80
Eva 90 100 90
David

Bob Alice Charlie Eva

</p>