loj#P3561. 「BalticOI 2021 Day2」The short shank; Redemption

「BalticOI 2021 Day2」The short shank; Redemption

Description

Well, that certainly didn’t go as planned: While you managed to avoid the museum’s watchmen, you somehow missed that there were surveillance cameras all over the place. As a consequence, your debut as an art thief turned out to be a total disaster: You were arrested and sentenced to prison.

Because WiFi access in prison is the worst, you want to escape. From many prison dramas, you know that distractions are crucial to any escape plan. Therefore, you decided to set up a prison rebellion as a ploy.

The 𝑁𝑁 prison cells are aligned along a single hallway. The leftmost cell is number 11, the cell immediately to its right is number 22, and so on. Unfortunately, not all your fellow prisoners join the rebellion as planned. But you could make sure that the prisoner in cell 𝑖𝑖 is planning to start rebelling at time tit_i,i.e. exactly tit_i seconds from now. Also, whenever a prisoner hears the prisoner immediately to his left rebelling, he will also start rebelling after just one second (unless he is already rebelling, of course).A prisoner who has started rebelling will never stop.

At time TT, the local F.R.U.IT.T.Ar.T. representative will arrive for an inspection. You figure that this will be the perfect time to escape. However, the prison wardens won’t be happy about a rebellion during an inspection. You are afraid they are going to use 𝐷𝐷 soundproof mattresses that can be installed between cells. If such a mattress is installed between cell 𝑖1𝑖 − 1 and cell 𝑖𝑖, the prisoner in cell 𝑖𝑖 will not start rebelling before time tit_i regardless of the actions of the prisoner in cell 𝑖 − 1 (or any other prisoner).

Write a program that helps you estimate your chances of success: The program shall compute the minimal number of prisoners who will rebel at time 𝑇𝑇 if the wardens place the mattresses optimally.

Input

The first line of input contains three integers 𝑁𝑁, 𝐷𝐷, and 𝑇𝑇: the number of prison cells, the number of mattresses, and the time the representative arrives.

The second line contains 𝑁𝑁 integers tit_i, where tit_i describes the time the prisoner in cell 𝑖𝑖 is planning to start rebelling.

Output

The only line of output should consist of exactly one integer: the minimal number of prisoners rebelling at time 𝑇𝑇.

5 1 42
13 37 47 11 42

4

5 2 5
1 9 4 6 7

2

Limits And Hints

We always have 1D<N2×1061 \le D<N \le 2 \times 10^6, 1T,ti1091 \le T,t_i \le 10^9.

  • Subtask 1(15 points): N500N \le 500.
  • Subtask 2(10 points): N5×105N \le 5 \times 10^5, D=1D=1.
  • Subtask 3(20 points): N4000N \le 4000.
  • Subtask 4(10 points): 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 further constraints.