Single-server queue simulation

Write codeHard35 min

Your task

Simulate a single-server queue deterministically. You are given a list of (arrival, service) tuples sorted by arrival time ascending (integers). The server processes one job at a time in arrival order (FIFO). A job's start time is the max of its arrival time and the previous job's finish time; its finish time is start + service. Return a list of finish times in input order. The list may be empty. All times are non-negative integers.

Examples

simulate_queue(jobs: list[tuple]) -> list[int]
Example 1
Inputsimulate_queue([[0, 3], [1, 2], [5, 1]])
Output[3, 5, 6]