Grade Statistics
InterviewTime limit1sMemory limit128 MB
For each class, read the scores, then report the maximum, the minimum, and the largest gap between neighboring scores after sorting in descending order.
- Level
Easy2 of 10
- Topics
- Sorting, Implementation, Array
- Solved
- No attempts yet
Problem
Han Sang-deok is the newly appointed principal of Jungdeok High School. His first job as principal is to compile statistics on each class's math exam scores.
Given the math exam scores of the students in each class, write a program that finds, for every class, the maximum score, the minimum score, and the largest difference between two adjacent scores when the scores are sorted in descending order.
Input
The first line contains the number of classes ().
Each of the next lines describes one class. The first integer on the line is the number of students () in that class, followed by the math scores separated by spaces. Each score is an integer between and , inclusive.
Output
For each class, print two lines.
- The first line is
Class X, where is the class number. It starts at and increases by in the order the classes are given in the input. - The second line is printed in the format
Max A, Min B, Largest gap C, where is the highest score in the class, is the lowest score, and is the maximum difference between two adjacent scores when the scores are sorted in descending order.