Can You Reach the End
From position i you may jump forward at most ai steps. Starting at position 1, can you reach position N?
Input: the first line has N; the second line has N non-negative integers.
Output: YES or NO.
Constraints:
- 1 ≤ N ≤ 105
- 0 ≤ ai ≤ 105
Sample Tests
Input 1
5 2 3 1 1 4
Output 1
YES
Input 2
5 3 2 1 0 4
Output 2
NO
Discussion (opens after you solve — no spoilers before)
No comments yet.