#C13463. Course Averages Calculator

    ID: 43004 Type: Default 1000ms 256MiB

Course Averages Calculator

Course Averages Calculator

You are given the grade records of several students. For each student, the input specifies the number of courses along with the course name and the respective grade. Your task is to compute the average grade for each course across all students. The average for a course is computed as ( \text{average} = \frac{\text{total grade}}{\text{number of entries}} ). Finally, print each course name followed by its average grade formatted to one decimal place, with courses sorted in lexicographical order. This problem tests your ability to aggregate data and format output correctly.

inputFormat

Standard Input Format: The first line contains an integer (N) denoting the number of students. For each student, the first line contains an integer (M) which denotes the number of courses that student has taken. The following (M) lines each contain a course name (a string without spaces) and a grade (a number), separated by a space. For example:

3 2 Math 80 Science 90 2 Math 85 English 88 3 Math 78 Science 82 English 95

outputFormat

Standard Output Format: For each course that appears in the input, print a line containing the course name followed by a space and its average grade formatted to one decimal place. The courses must be printed in lexicographical order. For the sample input above, the output should be:

English 91.5 Math 81.0 Science 86.0

If no student data is provided (i.e. N = 0), no output should be produced.## sample

3
2
Math 80
Science 90
2
Math 85
English 88
3
Math 78
Science 82
English 95
English 91.5

Math 81.0 Science 86.0

</p>