Grade Indicators (APCS 2016-03 Beginner)
Points 100 1.0s 256MIn an exam, among all students who passed, the one with the lowest score is the luckiest; conversely, among all students who failed, the one with the highest score can be considered the unluckiest. These two scores serve as the grade indicators of the exam.
Write a program that reads the scores of the whole class (the number of students is not fixed), sorts all the scores, and finds the highest failing score and the lowest passing score.
If the lowest passing score does not exist, this is an unfortunate class for this exam; in that case, print worst case. Conversely, if the highest failing score does not exist, print best case.
Note: the passing score is \(60\), and every score is an integer between \(0\) and \(100\).
Input
The first line contains the number of students \(n\).
The second line contains the \(n\) students' scores \(s_1, s_2, \ldots, s_n\), separated by exactly one space.
Constraints:
- \(1 \le n \le 20\)
- \(0 \le s_i \le 100\), all integers
- A score \(\ge 60\) counts as passing
Output
Output three lines:
The first line prints all scores in non-decreasing order, with exactly one space between adjacent numbers and no trailing space after the last number;
The second line prints the highest failing score; if everyone passed, print best case on this line;
The third line prints the lowest passing score; if everyone failed, print worst case on this line.
Scoring
The time limit for each test case is \(1\) second; your score is the sum over the test cases you pass.
Sample Input 1
10
0 11 22 33 55 66 77 99 88 44
Sample Output 1
0 11 22 33 44 55 66 77 88 99
55
66
Sample Explanation 1
The highest failing score is \(55\), and the lowest passing score is \(66\).
Sample Input 2
1
13
Sample Output 2
13
13
worst case
Sample Explanation 2
Since the lowest passing score does not exist, the third line must print worst case.
Sample Input 3
2
73 65
Sample Output 3
65 73
best case
65
Sample Explanation 3
Since the highest failing score does not exist, the second line must print best case.
Source
APCS programming exam, March 5, 2016, Problem 1.
Log in to write and submit code.
Log in