K - Jump

4.4

22 votes
Arrays, Data Structures, Medium, One-dimensional, Standard Template Library
Problem

Given an array A of size N, you can jump from an index i to another index j if A[j]A[i] >= K, for j > i. 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 K.

Second line contains the integer N.

Third line contains N space separated integers (The array A)

Output Format:

Print the required length.

Constrains:

1N,A[i],K ≤ 10 6

 

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

1 3 5 7 10 - Length 5

 

 

Editor Image

?