#C12684. Student Grades Processor

    ID: 42138 Type: Default 1000ms 256MiB

Student Grades Processor

Student Grades Processor

You are given a list of student grade entries. Each entry is a string formatted as Name:Grade, where Grade is supposed to be an integer. Your task is to:

  • Compute the average of all valid grades: \(\text{average} = \frac{\text{sum of valid grades}}{\text{number of valid grades}}\).
  • Determine the highest grade.
  • List the names (in alphabetical order) of the student(s) with the highest grade.
  • Record an error for each entry where the grade is not a valid integer with the message "Invalid grade for <Name>".

If there are no valid grades, return None for the average and highest grade, and empty lists for the student names and errors.

inputFormat

The input is provided via stdin in the following format:

  1. An integer \(n\) (in the first line) representing the number of student entries.
  2. \(n\) lines follow, each containing one string in the format Name:Grade.

outputFormat

The output should be printed to stdout as four lines:

  1. The first line contains the average grade (a floating-point number) or None if no valid grades exist.
  2. The second line contains the highest grade (an integer) or None if no valid grades exist.
  3. The third line is a JSON array (as a string) of names (sorted alphabetically) of the students with the highest grade. If none, print an empty list.
  4. The fourth line is a JSON array (as a string) of error messages. If no errors, print an empty list.
## sample
4
Alice:85
Bob:92
Charlie:85
David:89
87.75

92 ["Bob"] []

</p>