Code RoomBuild queue blocking cost
MediumPrep Room Coding #4866

Build queue blocking cost

CodingAlgorithms & data structuresMid–Senior~25 min

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.

Implement
min_blocked_minutes(minutes: list[int], blocked_engineers: list[int]) → int
Examples
in[[4,1],[1,5]]out10
in[[10,5],[3,1]]out45
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

0:00 of about 25 min
InputExpectedGot
[[4,1],[1,5]]10not run yetsample
[[10,5],[3,1]]45not run yetsample