#P4392. [BalticOI 2007] Sound 静音问题

[BalticOI 2007] Sound 静音问题

Description

In digital audio recording, sound is represented by a sequence of numbers describing air pressure, with each value called a sample, and adjacent samples separated by equal time intervals.

Many audio processing tasks need to split the recorded sound into non-silent segments separated by silence. To avoid producing too many or too few non-silent segments, silence is defined as follows: a sequence of mm samples in which the difference between the maximum and the minimum sample values does not exceed a given threshold cc.

Write a program to detect silence within nn samples.

Input Format

The first line contains three integers n,m,cn, m, c (1n1061 \le n \le 10^6, 1m1041 \le m \le 10^4, 0c1040 \le c \le 10^4), denoting the total number of samples, the length of a silence segment, and the maximum allowed noise level within a silence segment.

The second line contains nn integers aia_i (0ai1060 \le a_i \le 10^6), the value of each sample, separated by spaces.

Output Format

List all starting positions ii of silence segments (i.e., those ii such that $\max\{a_i, a_{i+1}, \ldots, a_{i+m-1}\} - \min\{a_i, a_{i+1}, \ldots, a_{i+m-1}\} \le c$). Output one starting position per line, in order of appearance. If there is no silence, output NONE.

7 2 0
0 1 1 2 3 2 2
2
6

Hint

Translated by ChatGPT 5