Job Scheduling
Time limit1sMemory limit32 MB
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 job requests to be handled over the next 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 days: if a request is submitted on day , it must be finished no later than day . In other words, a request submitted on day may be processed on any single one of the days .
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 , , and , where () is the number of days, () is the maximum allowed delay, and () is the number of job requests.
The second line contains exactly integers separated by single spaces; the -th integer is the day on which request is submitted. Every submission day is between and inclusive (no request is submitted after day ).
Output
Print a single integer: the minimum number of machines required to finish every job request within a delay of at most days.