Thread pool task completion times

Write codeMedium30 minMicrosoft style

Your task

A thread pool has workers identical worker threads. Tasks are submitted in order; task i has duration durations[i] and is submitted at submit_time times[i] (times is non-decreasing). When a task is submitted, if a worker is free it starts immediately; otherwise it waits in a FIFO queue and starts as soon as a worker frees up. Among queued tasks, the one submitted earlier starts first (ties broken by smaller index). Compute and return a list finish where finish[i] is the time task i completes. A task running for d units starting at time s finishes at s + d.

Examples

pool_finish_times(workers: int, times: list[int], durations: list[int]) -> list[int]
Example 1
Inputpool_finish_times(1, [0, 0, 0], [5, 3, 2])
Output[5, 8, 10]