#C1881. Average Score Calculation
Average Score Calculation
Average Score Calculation
You are given records of students and their scores in various subjects. For each student, compute the average score across all subjects. If a student has no subject scores, the average score is considered as 0. The average score must be rounded to two decimal places if necessary. Finally, output the results sorted in ascending order by the average score; if two students have the same average score, sort them alphabetically by their names.
Input is provided via standard input (stdin) and the output should be printed to standard output (stdout).
inputFormat
The first line contains an integer n, denoting the number of students. For each student, the following lines are given:
- A line with the student's name (a string).
- A line with an integer m, denoting the number of subjects.
- Then m lines follow, each containing a subject name (string) and an integer score separated by a space.
If m is 0, it means the student has no subject scores.
outputFormat
For each student, output a single line containing the student's name and their average score (rounded to two decimal places when necessary) separated by a space. The students must be printed in ascending order by average score; if two students have the same average score, they must be sorted alphabetically by name.## sample
5
Alice
2
math 90
science 80
Bob
2
english 75
history 85
Charlie
3
math 100
science 95
history 100
David
1
music 65
Eve
0
Eve 0
David 65
Bob 80
Alice 85
Charlie 98.33
</p>