Processing math: 100%
Small range - MarisaOJ: Marisa Online Judge

Small range

Time limit: 1000 ms
Memory limit: 256 MB
Given an integer array A of length n. Count the number of subarrays whose maximum and minimum values differ by no more than k. ### Input - The first line contains 2 integers n,k. - The second line contains n integers Ai. ### Output - Print the number of satisfied subarrays. ### Constraints - 1≤n,k≤105. - 1≤k≤109. - |Ai|≤109. ### Example Input: 411312 Output: 5