Least-loaded task assignment
Your task
A thread pool with workers worker threads (0..workers-1) processes a queue of tasks one unit of work at a time using a least-loaded assignment policy. Tasks arrive in order with cost costs[i]. Each task is assigned to the worker that currently has the smallest total assigned cost; ties are broken by the smaller worker id. Return a list load of length workers where load[w] is the total cost assigned to worker w after all tasks are placed.
Examples
assign_loads(workers: int, costs: list[int]) -> list[int]Example 1
Input
assign_loads(2, [3, 1, 2, 4])Output
[7, 3]