#C3080. Top K Unique Scores
Top K Unique Scores
Top K Unique Scores
You are given a series of test cases. For each test case, you will receive two integers \(n\) and \(k\) on one line, where \(n\) is the number of participants and \(k\) denotes the number of top unique scores to output. The next line contains \(n\) space-separated integers representing participants' scores.
Your task is to identify the unique scores, sort them in descending order, and then output the top \(k\) scores. If there are fewer than \(k\) unique scores available, output all unique scores.
The selection follows the process:
\(\text{unique\_scores} = \{ s \mid s \text{ appears in the list of scores} \}\)
and the result is:
\(\text{result} = \text{sorted}(\text{unique\_scores}, \text{reverse}=true)[:k]\)
inputFormat
The input is read from standard input (stdin). The first line contains a single integer \(T\) denoting the number of test cases. Each test case consists of two lines:
- The first line contains two space-separated integers \(n\) and \(k\).
- The second line contains \(n\) space-separated integers representing the scores.
outputFormat
For each test case, print a single line containing the top \(k\) unique scores in descending order, separated by a space. If the number of unique scores is less than \(k\), print all of them.
## sample2
6 3
70 80 80 90 70 60
5 4
50 50 50 50 50
90 80 70
50
</p>