#C12374. Jump Game

    ID: 41794 Type: Default 1000ms 256MiB

Jump Game

Jump Game

Given an array of non-negative integers, where each element represents the maximum jump length at that position, determine whether you can reach the last index starting from the first index.

For example, given the array ( [2, 3, 1, 1, 4] ), it is possible to reach the last index so the answer is ( True ). However, for ( [3, 2, 1, 0, 4] ) you cannot reach the end, thus the answer is ( False ).

Solve this problem by reading the input from standard input and printing the result to standard output.

inputFormat

The input consists of two lines. The first line contains an integer ( n ) (with ( 1 \leq n \leq 10^5 )), representing the number of elements in the array. The second line contains ( n ) space-separated non-negative integers, each representing the maximum jump length from that position.

outputFormat

Print ( True ) if it is possible to reach the last index, otherwise print ( False ).## sample

5
2 3 1 1 4
True

</p>