Given an array of length and starting at the 1st index, determine if it is possible to end exactly on the last index of the array, each time moving to the right by spaces and with indexes that cannot be moved to.
Input Specification
The first line will contain the integer , the length of the array, , the amount of spaces you move to the right by each time, and , the number of indexes that you cannot move to. The second line will either contain 1 or 0, 1 being the index can be moved to, and 0 meaning that the index has been blocked.
Output Specification
Output YES
if it is possible to end exactly on the last index of the array, otherwise output NO
.
Sample Input 1
7 3 2
1 0 1 1 0 1 1
Sample Output 1
YES
Comments