K-th Smallest in a Slice
Answer Q queries (l, r, k): the k-th smallest element of al..r. The array is static.
Input: the first line has N and Q; the second line has the array; the next Q lines have l r k.
Output: one line per query.
Constraints:
- 1 ≤ N, Q ≤ 105
- |values| ≤ 106
Sample Tests
Input 1
5 2 5 1 4 2 3 2 4 2 1 5 5
Output 1
2 5
Input 2
1 1 9 1 1 1
Output 2
9
Discussion (opens after you solve — no spoilers before)
No comments yet.