#P4392. Detecting Silence in Audio Samples

    ID: 17638 Type: Default 1000ms 256MiB

Detecting Silence in Audio Samples

Detecting Silence in Audio Samples

In digital audio recording, sound is represented as a sequence of numbers indicating the air pressure (samples), recorded at regular intervals. Many sound processing tasks require splitting the recorded sound into segments separated by silence. In this problem, silence is defined as any contiguous sequence of m samples in which the difference between the maximum and minimum sample does not exceed a given threshold c (i.e. \(\max - \min \le c\)).

You are given n samples. Your task is to determine how many sliding windows of length m are silent based on the definition above.

Note: The windows are contiguous and overlapping. For each i from 0 to n-m, you need to check the window [i, i+m-1].

inputFormat

The first line contains three integers n, m, and c where:

  • n is the number of samples.
  • m is the length of the window.
  • c is the threshold.

The second line contains n integers, representing the audio samples.

outputFormat

Output a single integer which is the number of contiguous windows of length m that are considered silence.

sample

6 3 2
1 3 2 2 5 4
2