#C6932. Student Report Generation

    ID: 50747 Type: Default 1000ms 256MiB

Student Report Generation

Student Report Generation

In this problem, you are given data for a number of students. Each student record consists of the student's name, age, and scores in three subjects: Math, Science, and Literature. Your task is to compute the average score for each student, round it to two decimal places, and then sort the records in descending order by the average score. If two or more students have the same average score, sort them alphabetically by their names.

The average score (\bar{x}) is computed as follows: [ \bar{x} = \frac{score_1 + score_2 + score_3}{3} ]

You need to read the input from standard input and print the sorted student reports to standard output. Each report must be in the format:

Name Average

Where "Name" is the student’s name and "Average" is the average score formatted with exactly two decimal places.

inputFormat

The input is read from standard input and has the following format:

  • The first line contains an integer (n) indicating the number of students.
  • The following (n) lines each contain a student's record consisting of the student's name (a string), age (an integer), and three integer scores for Math, Science, and Literature, separated by spaces.

For example:

3 Alice 20 80 75 90 Bob 22 85 90 80 Charlie 21 78 84 88

outputFormat

For each student, output a line containing the student's name and their average score, formatted to two decimal places. The output should be sorted in descending order by the average score. If multiple students have the same average score, they should appear in alphabetical order by their names.

For example, the output for the sample input should be:

Bob 85.00 Charlie 83.33 Alice 81.67## sample

3
Alice 20 80 75 90
Bob 22 85 90 80
Charlie 21 78 84 88
Bob 85.00

Charlie 83.33 Alice 81.67

</p>