#C14418. Top Students by Average Grade
Top Students by Average Grade
Top Students by Average Grade
You are given records of students. For each student, a record consists of a name and a list of grades in different subjects. Your task is to determine the student or students who achieve the highest average grade.
The average grade for a student is calculated by the formula:
$$\text{Average} = \frac{\sum_{i=1}^{n} grade_i}{n}$$
If multiple students have the same highest average grade, output all of their names in the order they appear in the input.
Note: The input is provided via stdin
and the output should be printed to stdout
. The names in the output should be separated by a single space.
inputFormat
The input begins with an integer n indicating the number of student records. Each of the following n lines describes one student record in the following format:
name m grade1 grade2 ... gradem
Where:
name
is a string representing the student's name.m
is an integer representing the number of grades for that student.gradei
are integers representing the student's grades.
If n is 0, the input contains no student records.
outputFormat
Output the name(s) of the student(s) with the highest average grade on a single line, separated by a single space. If there are no student records, output an empty line.
## sample3
Alice 3 90 95 88
Bob 3 85 92 91
Charlie 3 80 92 90
Alice
</p>