#P3834. 【模板】可持久化线段树 2
【模板】可持久化线段树 2
Description
As stated, given a sequence of integers, for each specified closed interval , query the -th smallest value within the interval.
Input Format
The first line contains two integers, the length of the sequence and the number of queries.
The second line contains integers; the -th integer is the -th element of the sequence.
Each of the next lines contains three integers , denoting the -th smallest value within the range .
Output Format
For each query, output one line with a single integer, the answer.
5 5
25957 6405 15770 26287 26465
2 2 1
3 4 1
4 5 1
1 2 2
4 4 1
6405
15770
26287
25957
26287
Hint
Sample 1 Explanation
, the sequence length is , and the sequence from the first term is .
- The first query asks for the first smallest value in , which is .
- The second query asks for the first smallest value in , which is .
- The third query asks for the first smallest value in , which is .
- The fourth query asks for the second smallest value in , which is .
- The fifth query asks for the first smallest value in , which is .
Constraints
- For of the testdata, .
- For of the testdata, .
- For of the testdata, .
- For of the testdata, , .
- For all testdata, , , , .
Translated by ChatGPT 5
京公网安备 11011102002149号