Build queue blocking cost

Write codeMedium25 min

Your task

A shared CI runner works through its queue one build at a time, starting at minute zero and never idling. Build i occupies the runner for minutes[i], and blocked_engineers[i] people can merge nothing until that build finishes, so each of them waits until the moment it ends. The cost of an order is the sum over builds of blocked_engineers[i] multiplied by that build's finish minute. You may run the queued builds in any order. Return the smallest cost any order achieves. Both lists have the same length, every duration is at least one minute, and at least one engineer waits on every build. An empty queue costs 0. Neither running the shortest build first nor clearing the most blocked build first is always right.

Examples

min_blocked_minutes(minutes: list[int], blocked_engineers: list[int]) -> int
Example 1
Inputmin_blocked_minutes([4, 1], [1, 5])
Output10
Example 2
Inputmin_blocked_minutes([10, 5], [3, 1])
Output45