All Tracks Data Structures Arrays 1-D Problem

K - Jump
/

Arrays, Data Structures, One-dimensional, Standard Template Library

Problem
Editorial
Analytics

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:

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

 

SAMPLE INPUT
2 
7
1 3 1 4 5 7 10
SAMPLE OUTPUT
5
Explanation

1 3 5 7 10 - Length 5

 

 

Time Limit: 1.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB

Best Submission

Similar Problems

Contributors

This Problem was Asked in

Initializing Code Editor...
Notifications
View All Notifications

?