K - Jump

4.4

22 votes
Problem

Given an array  of size , you can jump from an index  to another index  if >= , for  > . Find the length of the longest sequence of jumps that can be possible in the array. You can start at any index.

Input Format:

First line contains an integer .

Second line contains the integer .

Third line contains space separated integers (The array )

Output Format:

Print the required length.

Constrains:

 ≤

 

Sample Input
2 
7
1 3 1 4 5 7 10
Sample Output
5
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

1 3 5 7 10 - Length 5

 

 

Editor Image

?