Under construction

Still being built. Things may change

Job Scheduling

Time limit1sMemory limit32 MB

Summary
Find the minimum number of identical machines needed to schedule M jobs, each submitted on a day and requiring one day of processing within D days, over N days.
Level

Medium7 of 10

Topics
Greedy, Binary search, Simulation
Solved
No attempts yet

Problem

An engineering organization has received MM job requests to be handled over the next NN days. Processing one job takes exactly one full day on one machine. The organization owns several identical machines, and each machine can process at most one job per day, so on any given day it can process at most as many jobs as it has machines.

The organization accepts a delay of at most DD days: if a request is submitted on day SS, it must be finished no later than day S+DS + D. In other words, a request submitted on day SS may be processed on any single one of the days S,S+1,…,S+DS, S+1, \ldots, S+D.

Compute the minimum number of machines the organization needs so that every job can be processed within its allowed delay.

Input

The first line contains three integers NN, DD, and MM, where NN (1≤N≤1000001 \le N \le 100000) is the number of days, DD (0≤D<N0 \le D < N) is the maximum allowed delay, and MM (1≤M≤10000001 \le M \le 1000000) is the number of job requests.

The second line contains exactly MM integers separated by single spaces; the ii-th integer is the day on which request ii is submitted. Every submission day is between 11 and N−DN - D inclusive (no request is submitted after day N−DN - D).

Output

Print a single integer: the minimum number of machines required to finish every job request within a delay of at most DD days.

Examples5

  1. Example 1

    Input
    8 2 12
    1 2 4 2 1 3 5 6 2 3 6 4
    
    Expected output
    2
    
  2. Example 2

    Input
    1 0 1
    1
    
    Expected output
    1
    
  3. Example 3

    Input
    3 0 5
    2 2 2 2 2
    
    Expected output
    5
    
  4. Example 4

    Input
    5 2 5
    1 1 1 1 1
    
    Expected output
    2
    
  5. Example 5

    Input
    5 0 5
    1 2 3 4 5
    
    Expected output
    1