← 返回 google 的题目列表Multi-Elevator Controller: Scheduling and Dispatching
类型:online_judge
Coding/Design: Multi-Elevator Controller (Scheduling & Dispatch)
Implement an elevator controller that receives ride requests and decides which elevator should serve each request.
Input
Line 1: E F (#elevators, #floors, floors are 1..F) Line 2: E integers pos[i] initial floor of each elevator Line 3: N number of requests Next N lines: t from to (time, pickup floor, destination floor)
Output
For each request in input order, output the assigned elevator id (0..E-1).
Constraints
1 <= E <= 16, 2 <= F <= 200, 1 <= N <= 2e5, 0 <= t <= 1e9
Strategy
Implement either:
Path-first: minimize estimated incremental cost (distance/time) when inserting the request.
Fairness-first: prioritize long-waiting requests (e.g., aging) to avoid starvation.
What to implement
Elevator state model.
A dispatch(request) -> elevator_id function.
Explain scaling/throughput approaches for multiple elevators.
Example
Input
2 10
1 10
4
0 1 5
0 10 6
1 2 9
2 9 1
Output
0
1
0
1