On a certain route, buses are initially evenly spaced; however, due to the inconsistent traffic flow, one bus can get slightly delayed. As that bus becomes increasingly crowded due to the greater number of passengers at each stop, it gets delayed even further while the bus behind it catches up. This leads to buses travelling in packs where the first bus is full and the last one is almost empty.
As the buses (and especially the passengers) get jammed, one solution is to make the almost empty buses wait for a certain number of minutes so that there can be a reasonable gap.
Given a list of buses and the length of time that it is away from the terminus, find the minimum number of
Each bus has the choice of taking any number of
Input Specification
The first line of input will contain three space-separated integers,
The next
Output Specification
Output the minimum number of
It is guaranteed that it will be possible to achieve a headway of at most
Sample Input
5 2 10
1
13
23
35
44
Sample Output
4
Explanation for Sample Output
The first bus can take two breaks while the second and third buses can take one break each.
All headways are now
Comments
What would be the output for this case?
Output from my solution that AC'd:
Between the first bus and the second bus, there is 12 minutes of headway, but there needs to be 2 breaks? Shouldn't it be 1 break so that the headway is 10 minutes?
Edit: nvm, got it.
If the first bus takes a break, its value changes to 3, but then the other buses also have to take breaks...try solving for the sample on paper...