#C14942. Calculate Average Grades

    ID: 44647 Type: Default 1000ms 256MiB

Calculate Average Grades

Calculate Average Grades

You are given records for multiple students. For each student, you are provided with their name and a list of subjects with corresponding grades. Your task is to calculate the average grade for each student.

If a student does not have any grades (i.e. the list of subjects is empty), then the average grade is defined as 0.0.

The average grade is computed using the formula:

[ \text{average} = \frac{\sum_{i=1}^{m} g_i}{m} ]

where \(g_i\) is the grade of the \(i^{th}\) subject and \(m\) is the total number of subjects for that student.

The output should maintain the same order as the input.

inputFormat

The input is read from standard input (stdin) and is formatted as follows:

  • The first line contains a single integer \(n\) representing the number of students.
  • For each student, there are multiple lines:
    • A line containing the student's name (a string without spaces).
    • A line containing an integer \(m\) which denotes the number of subjects.
    • Then \(m\) lines follow, each containing a subject name and an integer grade separated by a space.

Note: If \(m = 0\), no subject lines follow for that student.

outputFormat

The output is written to standard output (stdout). For each student (in the same order as input), print a single line containing the student's name, a space, and their average grade formatted to one decimal place.

## sample
3
Alice
3
math 85
science 92
literature 78
Bob
2
math 79
science 85
Charlie
3
literature 91
math 83
science 87
Alice 85.0

Bob 82.0 Charlie 87.0

</p>