Round-robin scheduler simulation

Write codeHard40 minMicrosoft style

Your task

Simulate a deterministic single-threaded round-robin CPU scheduler with quantum Q. You are given tasks as [arrival_time, burst_time], indexed 0..n-1. At each scheduling moment the ready queue is processed FIFO; the running task executes for min(Q, remaining) time units, then if still unfinished re-enters the back of the queue. A task arriving at exactly the moment another is re-queued is enqueued BEFORE the re-queued task. If the CPU is idle and no task is ready, time jumps to the next arrival. Return a list of completion times indexed by task.

Examples

round_robin(tasks: list[list[int]], quantum: int) -> list[int]
Example 1
Inputround_robin([[0, 5], [1, 3]], 2)
Output[8, 7]