#C13087. Sort Students by Average Score
Sort Students by Average Score
Sort Students by Average Score
You are given a list of students along with their scores. Your task is to sort the students in descending order based on the average of their scores. If two or more students have the same average score, sort them in alphabetical order by their names.
The input will start with an integer N representing the number of students. Each of the next N lines contains a student’s name followed by an integer k denoting the number of scores, and then k integers representing the student’s scores. The output should print the sorted student names, each on a new line.
The sorting criteria can be expressed using the following formula:
\(\text{Sort key} = \Big(-\frac{\sum_{i=1}^{k} \text{score}_i}{k}, \text{name}\Big)\)
inputFormat
The first line contains a single integer N, the number of students. Each of the following N lines contains a student record in the following format:
Name k score1 score2 ... scorek
Where Name is the student's name, k is the number of scores, and score1, score2, ..., scorek are the scores of the student.
outputFormat
Output the sorted student names, each on a new line.
## sample3
Alice 3 100 90 80
Bob 3 70 60 50
Charlie 3 90 85 80
Alice
Charlie
Bob
</p>