#P8125. [BalticOI 2021] The short shank (Day2)
[BalticOI 2021] The short shank (Day2)
Description
You are in prison, and you are now in Luogu Prison No. 1.
The prison has cells, numbered from left to right as . You and your fellow prisoners are planning a rebellion. The prisoners in cell plan to rebel at time . If the prisoners in cell rebel, then the prisoners in cell will ignore their rule of rebelling at time and will instead rebel at time , where is the actual time when the prisoners in cell rebel.
The guards know everything in advance, so they will place mattresses. If a mattress is placed between cell and cell , then when the prisoners in cell rebel, the prisoners in cell will not rebel immediately, and will wait until time .
You want to know: after the guards arrange the mattresses in the best way, what is the minimum number of prisoners that will rebel at or before time .
Input Format
The first line contains three integers , representing the number of prisoners, the number of mattresses, and the target time.
The second line contains integers , representing the planned rebellion time of the prisoner in cell .
Output Format
Output one integer in one line, representing the answer.
5 1 42
13 37 47 11 42
4
5 2 5
1 9 4 6 7
2
Hint
Explanation of Sample 1
The optimal solution is to place a mattress between cell and cell . Then the prisoners in cells will rebel.
Constraints
This problem uses bundled testdata.
- Subtask 1 (15 pts): .
- Subtask 2 (10 pts): , .
- Subtask 3 (20 pts): .
- Subtask 4 (10 pts): , .
- Subtask 5 (25 pts): .
- Subtask 6 (20 pts): No special constraints.
For of the data, , .
There is also Subtask 0 as the sample.
Notes
Translated from BalticOI 2021 Day2 A The short shank。
Translated by ChatGPT 5
京公网安备 11011102002149号