#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 NN cells, numbered from left to right as 1N1 \sim N. You and your fellow prisoners are planning a rebellion. The prisoners in cell ii plan to rebel at time tit_i. If the prisoners in cell ii rebel, then the prisoners in cell i+1i+1 will ignore their rule of rebelling at time ti+1t_{i+1} and will instead rebel at time ti+1t'_i + 1, where tit'_i is the actual time when the prisoners in cell ii rebel.

The guards know everything in advance, so they will place DD mattresses. If a mattress is placed between cell ii and cell i+1i+1, then when the prisoners in cell ii rebel, the prisoners in cell i+1i+1 will not rebel immediately, and will wait until time ti+1t_{i+1}.

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 TT.

Input Format

The first line contains three integers N,D,TN, D, T, representing the number of prisoners, the number of mattresses, and the target time.

The second line contains NN integers tit_i, representing the planned rebellion time of the prisoner in cell ii.

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 22 and cell 33. Then the prisoners in cells 1,2,4,51, 2, 4, 5 will rebel.

Constraints

This problem uses bundled testdata.

  • Subtask 1 (15 pts): N500N \le 500.
  • Subtask 2 (10 pts): N5×105N \le 5 \times 10^5, D=1D = 1.
  • Subtask 3 (20 pts): N4000N \le 4000.
  • Subtask 4 (10 pts): N7.5×104N \le 7.5 \times 10^4, D15D \le 15.
  • Subtask 5 (25 pts): N7.5×104N \le 7.5 \times 10^4.
  • Subtask 6 (20 pts): No special constraints.

For 100%100\% of the data, 1D<N2×1061 \le D < N \le 2 \times 10^6, 1T,ti1091 \le T, t_i \le 10^9.

There is also Subtask 0 as the sample.

Notes

Translated from BalticOI 2021 Day2 A The short shank

Translated by ChatGPT 5