Flight Delays
InterviewTime limit2sMemory limit1024 MB
Given scheduled times t_i and a gap k, output each flight's departure: the max of t_i and the previous departure plus k.
- Level
Easy2 of 10
- Topics
- Simulation, Array
- Solved
- No attempts yet
Problem
Alyona is leaving on a long-awaited vacation. She is so afraid of missing her flight that she arrived at the airport at time . The departure board shows flights. Flight number (numbered from 1) must depart at time , and for all .
Unpredictable weather in city N has just brought heavy snow to the airport area. For safety, airport staff must clear snow from the runway after each flight departs, so the departure times of any two consecutive flights must differ by at least .
Alyona knows that flights depart in increasing order of their numbers. Each flight departs as early as possible, but no earlier than after the previous flight departs and no earlier than its scheduled time .
Alyona's mind is already on her vacation, so the task of finding the actual departure time of each flight falls to you. Flight 1 has no predecessor, so its runway does not need to be cleared.
Input
The first line contains two integers and (, ), the number of flights waiting to depart and the minimum gap between the departure times of two consecutive flights needed for runway clearing.
The second line contains integers (), the scheduled departure times.
Output
Print integers. The -th integer is the actual departure time of flight .
Hint
Look at the first example from the statement.
- The first flight departs on schedule.
- The second flight is delayed because the runway must be cleared.
- The planned gap between the third and second flights is enough for the third flight to leave on time, despite the second flight's delay and the clearing.
- The fourth flight departs on time.
- The fifth flight must be delayed, because the planned gap between it and the fourth flight was not large enough.
- The planned gap between the fifth and sixth flights was enough for clearing, but since the fifth flight was delayed, the sixth flight also departs late.