Grade Indicators (APCS 2016-03 Beginner)

Points 100 1.0s 256M

In 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.

Problem page help

Keyboard shortcuts

Main features

  • Sample tests — Runs the sample cases bundled with the problem and auto-compares against the expected output.
  • Custom test — Run your code with your own stdin. Optionally tick the "Compare with expected (diff)" box to verify against expected output line-by-line.
  • Template — Paste the default code template you set on your profile page.
  • Collab — Edit this problem together with classmates in real time.
  • Auto-draft — Editor contents auto-save to your browser every 1.5 seconds (per account / problem / language).
  • Submit — Send your code to the judge for grading; returns AC / WA / TLE etc.

Limits

  • Source code: at most 65,536 characters
  • Custom test stdin and expected output: at most 1 MB each (≈1 million characters)
  • Custom test and sample test share the sandbox; about 1 request per 3 s per user (sample test: 1 per 1 s)
  • Custom test and sample test both have a 15 second wall-clock cap (the official judge still uses the problem time limit)
  • Interactive problems do not offer custom test (cannot simulate interaction with the judge).
  • Submitting has no rate limit, but rapid repeated submissions on the same problem are treated as score farming.