#C14381. Report Card Generator
Report Card Generator
Report Card Generator
In this problem, you are required to generate a report card for a class of students. You are given the grades for each student, and you must compute both the individual student statistics and overall class statistics. For each student, calculate the average grade, the highest grade, and the lowest grade. The class statistics should include the overall class average, the highest grade in the class, and the lowest grade in the class.
The formulas are given by: ( \text{average};=;\frac{\sum_{i=1}^{n} grade_i}{n} ) ( \text{highest grade};=;\max(grade_1, grade_2, \ldots, grade_n) ) ( \text{lowest grade};=;\min(grade_1, grade_2, \ldots, grade_n) )
Input and output are done through standard input (stdin) and standard output (stdout) respectively. Note that if there are no students (i.e. an empty list), the class statistics should all be 0.
inputFormat
The input is given via stdin. The first line contains an integer N, the number of students. Each of the following N lines describes one student's record and has the following format:
Name K grade1 grade2 ... gradeK
Where Name is the student's name (a string without spaces), K is an integer representing the number of grades for that student, followed by K integers representing the grades. If N is 0, then there are no student records.
outputFormat
Output the report card as a JSON object with the following structure:
{ "StudentName": {"average_grade": float, "highest_grade": int, "lowest_grade": int}, ..., "class_statistics": {"class_average_grade": float, "highest_grade_in_class": int, "lowest_grade_in_class": int} }
Each student's statistics and overall class statistics must be computed as described. Print the JSON string to stdout.## sample
3
Alice 3 90 80 85
Bob 3 70 75 80
Charlie 3 60 65 70
{"Alice": {"average_grade": 85.0, "highest_grade": 90, "lowest_grade": 80}, "Bob": {"average_grade": 75.0, "highest_grade": 80, "lowest_grade": 70}, "Charlie": {"average_grade": 65.0, "highest_grade": 70, "lowest_grade": 60}, "class_statistics": {"class_average_grade": 75.0, "highest_grade_in_class": 90, "lowest_grade_in_class": 60}}