TopCoder

User's AC Ratio

100.0% (3/3)

Submission's AC Ratio

42.9% (3/7)

Tags

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 Format

$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}$

Output Format

Sample Input 1

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

Sample Output 1

1
4
1

Hints

  • $1 \leq N \leq 2 \times 10^ {5}$
  • $1 \leq Q \leq 2 \times 10^ {5}$
  • $0 \leq a_ i \leq 10^ {9}$
  • $0 \leq l_ i < r_ i \leq N$
  • $0 \leq k_ i < r_ i - l_ i$

Subtasks

No. Testdata Range Score

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 5000 2097152 2097152
1 5000 2097152 2097152
2 5000 2097152 2097152
3 5000 2097152 2097152
4 5000 2097152 2097152
5 5000 2097152 2097152
6 5000 2097152 2097152
7 5000 2097152 2097152
8 5000 2097152 2097152
9 5000 2097152 2097152
10 5000 2097152 2097152
11 5000 2097152 2097152
12 5000 2097152 2097152
13 5000 2097152 2097152
14 5000 2097152 2097152
15 5000 2097152 2097152
16 5000 2097152 2097152
17 5000 2097152 2097152
18 5000 2097152 2097152
19 5000 2097152 2097152
20 5000 2097152 2097152
21 5000 2097152 2097152
22 5000 2097152 2097152
23 5000 2097152 2097152