#P17197. [KOI 2026 #2] 删除局部最小值
[KOI 2026 #2] 删除局部最小值
Problem Description
You are given a sequence of length , consisting of pairwise distinct integers.
For a sequence , the following process is called one transformation:
- Let . For every integer satisfying (), call an element to be deleted. Delete all elements to be deleted from simultaneously, then keep the relative order of the remaining elements and concatenate them.
For example, after applying the transformation three times to the sequence , the sequence changes as follows:
You are given queries. Each query consists of three integers . For each query , output the number of elements remaining in the sequence after applying the transformation times.
Input Format
The first line contains two integers and , separated by spaces.
The second line contains integers , separated by spaces.
The next lines give the queries. Each line contains three integers , separated by spaces, representing one query.
Output Format
Output lines of answers starting from the first line. Print each query’s answer on its own line, in the same order as the input.
5 5
5 1 3 2 4
1 5 1
1 5 2
1 4 1
2 5 1
1 5 5
3
2
3
3
2
15 7
14 5 2 7 11 13 3 12 9 4 10 8 1 6 15
1 15 1
1 15 2
1 15 3
1 15 4
1 15 5
1 15 6
1 15 7
11
8
6
4
3
2
2
10 10
9 6 4 1 8 2 3 5 7 10
1 10 1
1 10 2
1 10 5
1 9 3
2 10 2
2 10 4
3 8 1
3 8 2
1 5 4
4 8 3
8
6
2
3
5
3
4
3
2
3
Hint
Constraints
- All given numbers are integers.
- .
- .
- The sequence is a permutation of , i.e., .
- For each query, .
- For each query, .
Subtasks
- ( points) ; for each query, and .
- ( points) For each query, and .
- ( points) For each query, .
- ( points) For each query, .
- ( points) There exists an integer () such that the following conditions both hold:
- For every integer (), .
- For every integer (), .
- ( points) After applying transformations to the sequence , applying further transformations will not change the sequence anymore.
- ( points) No additional constraints.
Translated by ChatGPT-5.6.
Translated by ChatGPT 5