PDP-25 (2013) - Phase C' - 2 (sound)

View as PDF

Submit solution

Points: 30 (partial)
Time limit: 1.0s
Memory limit: 64M

Author:
Problem types
Allowed languages
C, C++, Java, Pascal, Python

Sounds and Silences

In the digital recording of sound, sound is described by a sequence of N integers representing measurements at regular time intervals. Each value in the sequence is called a sample.

In many audio processing applications, we are interested in silences. Silences are intervals of samples of size M where the difference between the minimum and maximum value does not exceed a threshold value C.

Problem:

Develop a program in one of the IOI languages which, after reading the values of N, M, and C, as well as the integers corresponding to the digital recording of a sound, identifies the silences.

Input Files:

The input files named sound.in are text files with the following structure: The first line contains three integers N\;(1 \le N \le 1.000.000), M\;(1 \le M \le 10.000), and C\;(0 \le C \le 10.000), separated in pairs by a single space. The second line contains sequentially the N integers a[1], a[2], ..., a[N], corresponding to the samples of the digital sound recording, separated in pairs by a single space. These integers will be between 0 and 1.000.000.

Output Files:

The output files named sound.out are text files with the following structure: Each line contains one value of i such that

\displaystyle  max  \Big\{ a[i], \ldots \;a[i+M-1] \Big\}  - min \Big\{a[i], \ldots \;a[i+M-1]\Big\} \le C

The values of i should appear in ascending order.
Note: We assume that the numbering of samples starts from 1 (i.e., the first sample is a[1] and the last sample is a[N]).

If there is no such value of i, the output file should contain only one line with the word "NULL".

Example of Input - Output Files:

STDIN (sound.in)

7 2 0
0 1 1 2 3 2 2

STDOUT (sound.out)

2
6
Explanation of the Example:

In this example of N = 7 samples, a silence is a sequence of M = 2 samples where the difference between their minimum and maximum value does not exceed C = 0 (meaning silences are pairs of samples with the same value). There are two silences: 1, 1 (starting from position a[2]) and 2, 2 (starting from position a[6]).

Formatting: In the output, each line terminates with a newline character.
Maximum execution time: 1 sec.
Maximum available memory: 64 MB.


Comments

There are no comments at the moment.