Problem
Given N runways and a sequence of M plane operations (takeoffs and landings), assign each operation to a runway. A landing plane occupies a runway until it is moved to a dock; a departing plane frees its runway once airborne. A runway holds at most one plane at a time.
Input / Output
- Input: integer N (runways) and a stream of M operations, each a landing or a departure referencing the plane involved.
- Output: the runway assignment for each operation, and a queue/delay decision when no runway is free.
Constraints
- N runways, M operations.
- A runway holds at most one plane at a time.
- Operations arrive over time; when no runway is free an incoming operation must wait.
Example
- N = 1: land P1 (runway 0 now busy). A second landing arrives while runway 0 is busy -> it must queue. P1 is docked, freeing runway 0 -> the queued landing takes runway 0.