#C11787. K-th Ranked Score
K-th Ranked Score
K-th Ranked Score
Given several test cases, each containing a list of participant scores, your task is to find the score of the participant who ranks k-th when the scores are sorted in descending order.
For each test case, you are given:
- An integer \(n\): the number of participants.
- An integer \(k\): the rank you need to determine.
- A list of \(n\) integers representing the participants' scores.
The k-th highest score is defined by the following ordering:
\[ \text{score}_1 \geq \text{score}_2 \geq \cdots \geq \text{score}_n \]It is guaranteed that \(k\) is valid for the provided list of scores.
inputFormat
The input is read from stdin and consists of multiple test cases. The format is as follows:
T n1 k1 s11 s12 ... s1n1 n2 k2 s21 s22 ... s2n2 ... nT kT sT1 sT2 ... sTnT
Where:
- T is the number of test cases.
- For each test case, the first line contains two integers \(n\) and \(k\).
- The second line contains \(n\) integers representing the scores.
outputFormat
For each test case, output the k-th highest score on a separate line to stdout.
## sample2
5 2
50 30 40 10 20
4 1
100 90 80 70
40
100
</p>