Problem8828--[yosupo] Data Structure - Range Kth Smallest

8828: [yosupo] Data Structure - Range Kth Smallest

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 512 MiB

Description

You are given an integer sequence $a_0, a_1, ..., a_{N-1}$ with the length $N$.
Process the following $Q$ queries in order:

- $l_i$ $r_i$ $k_i$: Print $k_i+1$ th smallest value in $(a_{l_i}, a_{l_i + 1}, ..., a_{r_i - 1})$.

Input

$N$ $Q$
$a_0$ $a_1$ ... $a_{N - 1}$
$l_0$ $r_0$ $k_0$
$l_1$ $r_1$ $k_1$
:
$l_{Q-1}$ $r_{Q-1}$ $k_{Q-1}$

Constraints

$1 \leq N \leq 200000$
$1 \leq Q \leq 200000$
$0 \leq a_i \leq 10^9$
$0 \leq l_i < r_i \leq N$
$0 \leq k_i < r_i - l_i$

Sample 1 Input

5 3
1 4 0 1 3
0 5 2
1 3 1
3 4 0

Sample 1 Output

1
4
1

HINT

相同题目:yosupo

Source/Category