Snowstorm
Time limit1sMemory limit128 MB
Simulate plows clearing road intervals in order of smallest remaining uncovered length and print the clearing order.
- Level
Medium6 of 10
- Topics
- Intervals, Simulation, Heap, Sorting
- Solved
- No attempts yet
Problem
A snowstorm hit the main road. There are plows; plow covers interval . Intervals may overlap but none lies entirely inside another. They need not cover the whole road.
One operator runs every plow. Each time, pick the plow whose assigned interval still has the least uncovered length. Tie-break by smaller index. A road point needs clearing only once.
Input
Line 1: , . Next lines: , with increasing .
Output
Print lines: plow numbers in clearing order.