#K91637. Marathon Jump Challenge
Marathon Jump Challenge
Marathon Jump Challenge
You are given a marathon track of length L meters. The finish line is at position L - 1 (0-indexed). A participant can jump up to J meters in one leap. Certain positions on the track have obstacles. The participant cannot land on an obstacle.
The task is to determine whether the participant can reach the finish line by performing a series of jumps. At each step, the participant will choose the largest possible jump (from J down to 1) that lands on a non-obstacle cell. Additionally, if a jump would land at or beyond the finish line, the participant successfully finishes the race.
The jumping strategy can be summarized as:
\( \text{while } current + i < L \text{ for } i \in \{J, J-1, \dots, 1\} \)
If no jump is possible at a given position, the answer is "NO"; otherwise, if the finish line is reached (or overshot), the answer is "YES".
inputFormat
The first line of input contains three space-separated integers: L (length of the track), J (maximum jump distance), and O (number of obstacles).
The second line contains O space-separated integers indicating the positions of the obstacles. If O is 0, the second line will be empty.
outputFormat
Output a single line containing either "YES" if the participant can reach the finish line, or "NO" otherwise.
## sample10 2 3
1 4 6
YES