The Top 3 Scores
The weekly quiz at Fenwick College publishes a podium: the three best scores of the round, best first. Equal scores are not merged. If two players tie, both of their scores appear on the podium and the podium still names three. The scores reach the publisher in the order the papers were marked, which has nothing to do with rank, and there are always at least three of them.
Task: Print the three highest scores, highest first.
Input
The first line holds a single integer n, the number of scores; n is at least 3. Each of the next n lines holds one score: a whole number.
Output
One line holding exactly three scores in decreasing order, separated by single spaces. A value that occurs more than once among the top three is printed each time it occurs.
Example:
Input:
5
40
90
60
100
75
Output:
100 90 75
Sign in to solve this problem
Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.
Sign in