#B3798. Ranking by Exam Score Volatility

    ID: 11455 Type: Default 1000ms 256MiB

Ranking by Exam Score Volatility

Ranking by Exam Score Volatility

Dream Bear XINAO is committed to nurturing high-quality contest talents. In order to ensure full attention to the learning status of students, especially those whose scores fluctuate significantly, we need to monitor the volatility of student scores.

In a class with n students who participated in m exams, the volatility of a student’s performance is measured by the standard deviation. The standard deviation is given by the formula:

$$\sigma = \sqrt{\dfrac{\sum (X-\mu)^2}{N}}$$

where:

  • X is the score in one exam,
  • \(\mu\) is the mean of all exam scores of that student,
  • N is the number of exams taken, and
  • \(\sum\) denotes the summation over all exams.

A smaller standard deviation indicates more stable performance.

For example, if a student has scores 40, 50, 60 in three exams, then the standard deviation is computed as:

$$\sigma = \sqrt{\dfrac{(40-50)^2+(50-50)^2+(60-50)^2}{3}} = \dfrac{10\sqrt{6}}{3} \approx 8.16$$

Your task is to sort the students in descending order according to the volatility of their scores (i.e. the standard deviation), and output only the top 20 students with the highest volatility (if there are fewer than 20 students, output them all). The input will provide each student’s name and their scores for each exam.

inputFormat

The first line contains two integers n and m separated by a space, representing the number of students and the number of exams respectively.

Each of the following n lines contains a student name (a single string without spaces) followed by m space-separated integer scores.

Example:

4 3
Alice 40 50 60
Bob 100 100 100
Charlie 30 50 80
David 10 80 90

outputFormat

Output the names of the top 20 students (or all if fewer than 20) sorted in descending order of score volatility, one per line.

For the sample input above, the output should be:

David
Charlie
Alice
Bob

sample

4 3
Alice 40 50 60
Bob 100 100 100
Charlie 30 50 80
David 10 80 90
David

Charlie Alice Bob

</p>