Path Running

View as PDF

Submit solution

Points: 3
Time limit: 1.0s
Memory limit: 64M

Author:
Problem type

Given an array of length N 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 K spaces and with M indexes that cannot be moved to.

Input Specification

The first line will contain the integer N (1 \leq N \leq 10^5), the length of the array, K (1 \leq K \leq 10^5), the amount of spaces you move to the right by each time, and M (0 \leq M \leq N), 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

There are no comments at the moment.