#C13165. Average Score Computation

    ID: 42673 Type: Default 1000ms 256MiB

Average Score Computation

Average Score Computation

You are given records for a number of students. Each record contains the student's name and a list of subject scores. Your task is to compute the average score for each student using the formula below and output the results in JSON format.

The average score for a student is defined as:

[ \text{average} = \frac{\sum_{i=1}^{n} s_i}{n} ]

where \(s_i\) is the score in a subject and \(n\) is the number of subjects that student has scores for. The average must be rounded to one decimal place.

If a student does not have any subject scores (i.e. the number of subjects is 0), they must not appear in the output.

inputFormat

The input is provided via stdin in the following format:

N
Name1 M1 subject1 score1 subject2 score2 ... subjectM1 scoreM1
Name2 M2 subject1 score1 subject2 score2 ... subjectM2 scoreM2
... 

where:

  • N is the number of students.
  • Each of the next N lines starts with a student's name (a string without spaces) followed by an integer M representing the number of subjects.
  • Then, for each student, there are M pairs where each pair consists of a subject name (a string) and a score (an integer or float).

Note: If M is 0, the student has no scores.

outputFormat

Output a JSON object to stdout where each key is a student's name and its value is the average score (rounded to one decimal place) for that student. Students with no scores should not appear in the output.

For example, an output might look like:

{"Alice": 88.5, "Bob": 78.0, "Charlie": 80.0}
## sample
3
Alice 2 math 85 science 92
Bob 1 math 78
Charlie 3 science 70 math 80 english 90
{"Alice": 88.5, "Bob": 78.0, "Charlie": 80.0}