LearnPy Hub
← Arena
AdvancedRating 1800

Blocks With Small Spread

Count the blocks of consecutive numbers in which (maximum − minimum) ≤ k.

Input

n and k, then n integers.

Output

One integer.

Sample 1

Input
4 2
5 4 2 4
Output
8

Sample 2

Input
3 0
1 2 3
Output
3
solution.py
Output appears here
Blocks With Small Spread · Python Arena problem · LearnPy Hub