#P1923. 【深基9.例4】求第 k 小的数

【深基9.例4】求第 k 小的数

Description

Given nn numbers aia_i, output the kk-th smallest among them. The smallest number is the 00-th smallest.

Please try not to use nth_element for this problem, because the main point is to practice divide and conquer algorithms.

Input Format

The first line contains two integers, which are nn and kk.

The second line contains nn integers, and the ii-th number is aia_i.

Output Format

Output one integer, the kk-th smallest number.

5 1
4 3 2 1 5

2

Hint

For 100%100\% of the testdata, 1ai<1091 \le a_i < {10}^9, 1n<5×1061 \le n < 5 \times 10^6, and nn is odd.

Translated by ChatGPT 5