Loading content...
A resource processor needs to consume materials from multiple stockpiles before an external event occurs. There are n stockpiles of materials, where the i-th stockpile contains stockpiles[i] units of material. The processor has a limited time window of deadline hours before the event.
The processor operates at a fixed consumption rate of k units per hour. During each hour, the processor selects one stockpile and consumes up to k units from it. If a stockpile contains fewer than k units remaining, the processor consumes all remaining units from that stockpile and idles for the remainder of that hour (it cannot switch to another stockpile mid-hour).
The processor prefers to operate at a slower, more energy-efficient rate while still completing all consumption before the deadline.
Your task is to determine the minimum integer consumption rate k such that the processor can consume all materials from all stockpiles within the given deadline hours.
stockpiles = [3,6,7,11]
deadline = 84With a consumption rate of 4 units/hour:
stockpiles = [30,11,23,4,20]
deadline = 530With only 5 hours available and 5 stockpiles, each stockpile must be processed in exactly 1 hour. The largest stockpile has 30 units, so the minimum rate must be at least 30 to handle it in one hour. Rate of 30 allows each stockpile to be processed in 1 hour each.
stockpiles = [30,11,23,4,20]
deadline = 623With 6 hours and 5 stockpiles, we have 1 extra hour. At rate 23:
Constraints