#C8904. Frog Jump Reachability

    ID: 52938 Type: Default 1000ms 256MiB

Frog Jump Reachability

Frog Jump Reachability

Given an array of non-negative integers where each element represents the maximum number of steps a frog can jump from that index, determine whether the frog can reach the last index of the array starting from the first index. At each position ( i ), the frog can jump to any index ( j ) such that ( i < j \leq i + a_i ). A common greedy strategy is to keep track of the farthest reachable index using the recurrence formula: ( r_i = \max(r_{i-1}, i + a_i) ). Output true if the frog can reach the last index, or false otherwise.

inputFormat

The input consists of two lines. The first line contains an integer ( n ) representing the number of elements in the array. The second line contains ( n ) space-separated integers representing the maximum jump lengths from each position.

outputFormat

Output a single word: true if the frog can reach the end of the array, or false if it cannot.## sample

5
2 3 1 1 4
true

</p>