Fixed thread pool dispatcher
Your task
Simulate a fixed thread pool with W worker threads pulling from a FIFO task queue. tasks is a list of [submit_time, duration] given in submission order. A task can only start at or after its submit_time. Whenever a worker is free and the queue head's submit_time has arrived, the head is assigned to the lowest-indexed free worker and runs to completion (non-preemptive). Tasks must be dispatched in FIFO order (a later-submitted task cannot start before an earlier one is dispatched, even if a worker is idle and the later task has arrived). Return a list of [worker_index, start_time, end_time] for each task in the SAME order as the input tasks list.
Examples
thread_pool_sim(w: int, tasks: list[list[int]]) -> list[list[int]]Example 1
Input
thread_pool_sim(2, [[0, 5], [0, 3], [1, 2]])Output
[[0, 0, 5], [1, 0, 3], [1, 3, 5]]