eolymp
bolt
Try our new interface for solving problems
Problems

K-th element

K-th element

Array $a$ of $n$ integers and number $k$ are given. Find the $k$-th element in a sorted array $a$ (indexing starts from $1$). \InputFile First line contains two integers $n$ and $k~(1 \le n \le 2000, 1 \le k \le n)$. Second line contains $n$ integers $a_i~(1 \le i \le n, 1 \le a_i \le 2000)$. \OutputFile Print the $k$-th element in a sorted array $а$.
Time limit 1 second
Memory limit 128 MiB
Input example #1
2 1
2 1
Output example #1
1
Input example #2
5 3
4 7 1 8 12
Output example #2
7