#C8439. K-th Highest Score

    ID: 52421 Type: Default 1000ms 256MiB

K-th Highest Score

K-th Highest Score

You are given the scores of n competitors and a positive integer k. Your task is to determine the k-th highest score.

Formally, given a list of scores \(\{s_1, s_2, \dots, s_n\}\), sort them in descending order to obtain \(\{s_{(1)}, s_{(2)}, \dots, s_{(n)}\}\), and output \(s_{(k)}\) (where indexing is 1-based).

The problem expects you to read input from standard input (stdin) and write the result to standard output (stdout).

inputFormat

The input consists of two lines.

  • The first line contains two integers \(n\) and \(k\), where \(n\) is the number of competitors and \(k\) is the position of the highest score to find (1-based index).
  • The second line contains \(n\) space-separated integers representing the scores of the competitors.

It is guaranteed that \(1 \leq k \leq n\).

outputFormat

Output a single integer, which is the \(k\)-th highest score among the given competitor scores.

## sample
5 2
100 200 150 170 90
170