#C1171. Reach the Last Platform

    ID: 41056 Type: Default 1000ms 256MiB

Reach the Last Platform

Reach the Last Platform

Chef is on an adventure across a series of platforms. Each platform is associated with a jump power. Chef starts at the first platform (index 0) and can jump to other platforms according to the jump power at his current position. The objective is to determine whether Chef can reach the last platform of the level.

For each test case, you are given an integer ( N ) representing the number of platforms, followed by ( N ) integers where the ( i )-th integer (0-indexed) represents the maximum jump length from that platform. Chef begins on the first platform, and at any platform ( i ), he can jump to any platform ( j ) such that ( i \leq j \leq i + A_i ). Your task is to check if Chef can reach the platform at index ( N-1 ) from the starting point.

Note: The jump power from a platform may be zero, which means Chef cannot move forward from that platform. Use simulation or greedy algorithms to determine if the last platform is reachable.

inputFormat

The first line of input contains an integer \( T \), the number of test cases. Each of the next \( T \) lines represents a single test case and contains \( N+1 \) space-separated integers. The first integer is \( N \), the number of platforms, followed by \( N \) integers representing the jump power on each platform.

Example:
3 5 2 3 1 1 4 6 2 2 0 1 4 2 4 1 0 0 1

outputFormat

For each test case, output a single line containing either YES if Chef can reach the last platform, or NO otherwise.

Example:
YES YES NO

## sample
3
5 2 3 1 1 4
6 2 2 0 1 4 2
4 1 0 0 1
YES

YES NO

</p>