#C6854. K-th Best Participant Score
K-th Best Participant Score
K-th Best Participant Score
In a programming competition, each participant receives a score. Some participants may receive the same score, and they are considered tied. You are given the number of participants (n), the position (k), and the list of scores. The task is to determine the (k)-th best score considering only unique scores sorted in descending order. Formally, if (S) represents the set of unique scores sorted in descending order, you need to output (S[k-1]) (using 0-indexing). It is guaranteed that (k) does not exceed the number of unique scores.
Input/Output Format: The problem requires reading from standard input (stdin) and printing the answer to standard output (stdout).
inputFormat
The first line contains two integers (n) and (k), where (n) is the number of participants and (k) is the position of the unique score you want to determine. The second line contains (n) integers separated by spaces representing the scores of the participants.
outputFormat
Output a single integer which is the (k)-th best unique score when the scores are sorted in descending order.## sample
5 2
10 20 20 15 30
20