Hints — p90 Single-Threaded CPU

  1. This is Shortest Job First (SJF) non-preemptive with tie-break by original index.

  2. Sort tasks by enqueueTime (keeping original index). Walk a pointer through the sorted list.

  3. Maintain a min-heap of (proc_time, original_idx) for ready tasks. Tuple comparison handles SJF + tie-break automatically.

  4. Fast-forward: when CPU is idle (heap empty), jump cur_time to next task’s enqueue time. Don’t simulate every clock tick.

  5. Each iteration: push all arrived tasks (enqueue ≤ cur_time); pop the smallest (proc_time, idx); append idx to order; advance cur_time.

If stuck: see solution.py.