Hunting the Snark
Problem
At the initial moment of time, the Snark is located at a point of a straight line with an integer non-negative coordinate X. During the move, he can be at any point with an integer Y coordinate, provided that |X-Y| <= S. Also, the Snark doesn't like buns, so he'll never jump into a cage with one of those nasty things in it. The baker doesn't want the Snark to get home. After each move of the Snark, the Baker can place the bun at any point on the line, provided that it is not the origin (Snark's home) and there is no Snark in that cell. Determine if the Baker can stop the Snark from getting home. Initially, some cells contain buns.
Input
The first line contains integers 0 <= X < 10000, 0 < S <= 100 and 0 <= N < max(X-1, 0) - the number of buns that already lie on the line. Next come N different numbers 0 < bi < X - coordinates of the points where the muck lies.
Output
Print "YES" if the Baker can realize his dirty plans, "NO" - if the Snark can jump home with any actions of the enemy.
Enter |
Output |
1 1 0
|
NO |
|
YES |