#C2864. Top Three Highest Unique Values
Top Three Highest Unique Values
Top Three Highest Unique Values
You are given a list of integers. Your task is to find the top three highest unique values in the list and output them in descending order. If there are fewer than three unique numbers, output all the unique numbers in descending order.
The solution should read input from standard input (stdin) and write output to standard output (stdout). The input will start with an integer n which indicates the number of integers in the list, followed by a line containing n space-separated integers.
For example, given the list [4, 1, 4, 3, 2, 5]
, the top three highest unique values are 5, 4, 3
.
The requirement can be summarized by the following formula, where \(U\) is the set of unique elements and \(sorted(U)\) denotes the set sorted in descending order: \[ answer = sorted(U)[0:3] \]
inputFormat
The input consists of two lines. The first line contains a single integer n (0 \(\leq\) n \(\leq\) 105), representing the number of integers. The second line contains n space-separated integers.
outputFormat
Output the top three highest unique numbers in descending order, separated by a space. If there are less than three unique numbers, output all of them in descending order. If there is no number, output an empty line.
## sample6
4 1 4 3 2 5
5 4 3