#P6092. [CEOI 2012] 工作规划

[CEOI 2012] 工作规划

Description

CEOI received MM tasks over NN days. Each task needs 11 machine working for 11 day to be completed. CEOI has many machines, and each machine can complete at most one task per day. CEOI requires that each task can be delayed by at most DD days. In other words, if a customer submits a task on day SS, CEOI must finish it by day S+DS + D.

Please write a program to find the minimum number of machines needed to complete all tasks on time, under the constraint that each task can be delayed by at most DD days.

Input Format

The first line contains three integers: NN is the number of days during which CEOI receives tasks, DD is the maximum number of days each task can be delayed, and MM is the number of tasks.

The second line contains MM integers separated by spaces. The ii-th number represents the day when the ii-th task is received. There are no tasks after day NDN - D. All tasks are numbered from 11 to NN in order of the input.

Output Format

Output one integer, the minimum number of machines that can complete the tasks.

8 2 12 
1 2 4 2 1 3 5 6 2 3 6 4
2

Hint

For 50%50\% of the testdata, M105M \le 10^5.

For all testdata, 1N1051 \le N \le 10^5, 0D<N0 \le D < N, 1M<1061 \le M < 10^6.

Translated by ChatGPT 5