Compute the minimum total cost to satisfy EV charging demand across slots.
You are given n (number of vehicles), t (number of charging slots), mc (maximum capacity of each slot), vehicles[] (charging requirement of each vehicle), costs[] (cost per unit at each slot) and penalty (penalty per unit of unfulfilled energy). The total requirement is the sum of all vehicle requirements and can be distributed among vehicles in any manner. Each slot provides at most mc units. Any unfulfilled energy costs the penalty per unit. A slot can be skipped if its cost per unit is greater than the penalty. Find the minimum total cost.
Example: n = 3, t = 4, mc = 6, vehicles = [5, 7, 3], costs = [10, 4, 8, 20], penalty = 9. Total requirement 15; use the cost-4 slot for 6 units (24) and the cost-8 slot for 6 units (48), leave 3 units to penalty (27), total 99. Slots costing 10 and 20 are skipped because they exceed the penalty.
Community answers
Related questions
Compute the minimum total cost of repeatedly merging the two smallest numbers.Find the minimum total cost to make an array non-decreasing.Related courses


