#K15306. Top Three Participants
Top Three Participants
Top Three Participants
You are given the number of participants in a competition and their corresponding skill ratings. Your task is to determine the top three participants by their ratings. If there are fewer than three participants, output all of them. The ratings should be sorted in descending order (from highest to lowest).
The input is given via standard input and the result must be printed via standard output. For example, if you have 5 ratings, print the top 3 ratings separated by a single space.
Constraints: \(1\leq n \leq 10^5\) and \(0\leq rating \leq 10^6\).
inputFormat
The first line contains an integer n
representing the number of participants.
The second line contains n
space-separated integers denoting the skill ratings of each participant.
outputFormat
Print the top three (or fewer if less than three participants) skill ratings in descending order separated by a space.
## sample5
8 2 5 1 7
8 7 5
</p>