#C8631. Wizard Communication Relay
Wizard Communication Relay
Wizard Communication Relay
In this problem, you are given (N) wizards arranged in a circle. Each wizard has a specific power level. Two adjacent wizards can directly communicate if the absolute difference of their power levels is at most (K), i.e. (|a - b| \le K). Note that the circle is cyclic, so the first and the last wizard are also considered adjacent. Your task is to determine whether it is possible to relay a message throughout all the wizards.
inputFormat
The input consists of two lines. The first line contains two space-separated integers (N) (the number of wizards) and (K) (the maximum allowed power difference). The second line contains (N) space-separated integers representing the power levels of the wizards.
outputFormat
Output a single line containing either "Yes" if the message can be relayed among all wizards, or "No" otherwise.## sample
6 5
1 2 3 8 7 5
Yes