Worker Pool Scheduler

You operate the dispatch service of a render farm that employs n specialist workers numbered 0 through n - 1. Producers submit job offers ahead of time; the j-th offer arrives as jobs[j] = [ready_j, due_j]. The work becomes ready at moment ready_j and occupies whichever single worker accepts it for exactly due_j - ready_j units of time. A worker can hold at most one job at a time.

The dispatcher follows a strict deterministic policy:

  1. Offers are dispatched in increasing order of ready time. Offers that share a ready time are dispatched in submission order, so a lower index goes first.
  2. At dispatch, if at least one worker is idle, the offer goes to the idle worker with the smallest number.
  3. If every worker is busy, the offer waits in line. As soon as some worker frees up, the longest-waiting waiting offer starts on it immediately and keeps its full duration; only its window slides forward by the length of the wait. Waiting offers are served in dispatch order. When several workers free at the same instant, they are taken lowest number first.
  4. Occupancy is half-open: a worker finishing at moment t becomes available exactly at t, so it may accept an offer whose work starts at t.

A delayed offer finishes at its actual start plus its duration. Return the number of the worker that completes the most jobs. If several workers tie on completed jobs, return the smallest such number.

Examples
Input: [2,[[0,9],[1,2],[3,4],[5,6],[9,10]]]
Output: 1
Hints

Worker Pool Scheduler

You operate the dispatch service of a render farm that employs `n` specialist workers numbered `0` through `n - 1`. Producers submit job offers ahead of time; the `j`-th offer arrives as `jobs[j] = [ready_j, due_j]`. The work becomes ready at moment `ready_j` and occupies whichever single worker accepts it for exactly `due_j - ready_j` units of time. A worker can hold at most one job at a time.