#K15506. Train Scheduling
Train Scheduling
Train Scheduling
You are given T trains arriving at a single platform. For each train, its arrival time is provided in order. Two trains cannot be scheduled simultaneously on the same platform. In other words, if the difference between the arrival time of the ith train and the (i-1)th train is less than 1 (i.e. if \(a_i - a_{i-1} < 1\)), then a scheduling conflict occurs.
Your task is to determine if all trains can be scheduled without any conflicts. If they can be scheduled, output Yes
; otherwise, output No
.
inputFormat
The input consists of two lines:
- The first line contains an integer T, representing the number of trains.
- The second line contains T space-separated integers representing the arrival times of the trains. It is guaranteed that the arrival times are given in non-decreasing order.
outputFormat
Output a single line containing either Yes
if the trains can be scheduled without conflicts, or No
otherwise.
5
1 2 5 6 7
Yes