cswork / OAOpen practice workspace

SuperhumanOA #2

Math Homework

Estimated MediumJudge-ready

Topics (AI-labelled)Greedy

Start from index 0 and move +1 or +2 at each step; stop as soon as the spread of the solved points first reaches threshold; if it can never be reached, solve the entire array as the problem states.

See "Input" for the standard input/output conventions and constraints added by this site.

Input

points is non-decreasing, n≤100000, and the values and threshold are in 1..999.

Output

Output the minimum number of problems; if the threshold cannot be reached, output n.

Example 1

Input:

5 4
1 2 3 5 8

Output:

3

Example 2

Input:

5 4
1 2 3 4 5

Output:

3

Example 3

Input:

4 10
4 5 6 7

Output:

4

Example 4

Input:

1 1
1

Output:

1

Editorial

Loading solution…