Music
InterviewTime limit1sMemory limit128 MB
Count length-m windows whose max minus min is at most c, across several small arrays.
- Level
Easy3 of 10
- Topics
- Sliding window, Array
- Solved
- No attempts yet
Problem
Silence is useless. We want the world to be full of music. In computer music, the volume is represented as an integer array of length . A silence in music is defined by two parameters and . A silence occurs in any contiguous subarray of length in which the difference between the maximum element and the minimum element is at most .
For example, if the volume array is with and , then silence occurs in the length-3 subarrays starting at indices 0, 4, and 5. Output the total number of silence intervals.
Input
The first line contains an integer, the number of data sets that follow. Each data set consists of two lines. The first line contains three integers , , and (, , ). The second line contains integers representing the volume array; each integer is at most .
Output
For each data set, print the total number of silence intervals.