1342: [Baltic2007]sound mute problem

Source: Internet
Author: User

1342: [Baltic2007]sound Mute issue time limit:5 Sec Memory limit:162 MB
submit:710 solved:307
[Submit] [Status] [Discuss] Description Mute problem in digital recording, the sound is described by a sequence of numbers that represent air pressure, each of which is called a sample, and the interval between each sample is a certain amount of time. Many sound processing tasks require that the recorded sound be divided into a few non-silent segments separated by silence. To avoid dividing into too many or too few non-silent segments, muting is usually defined as: M-sampled sequences, where the difference between the maximum and minimum values sampled in the sequence does not exceed a specific threshold of C. Please write a program to detect the Silence in N samples. The first line of input has three integers n,m,c (1<= n<=1000000,1<=m<=10000, 0<=c<=10000), respectively, representing the total number of samples, the length of the mute, and the maximum allowable noise level in silence. The 2nd row n integer ai (0 <= ai <= 1,000,000) represents each sampled value of the sound, separated by a space between every two integers. Output lists all mute start positions I (I meet Max (A[i, ..., i+m−1]) −min (a[i, ..., i+m−1]) <= c), each line represents the starting position of a mute, in the order in which it appears. If there is no mute, the output is none. Sample Input7 2 0
0 1 1 2 3 2 2
Sample Output2
6
HINT Source

The direct monotone queue water water da ...
1 var2 A3,a4,a1,a2,i,j,k,l,m,n,c:longint;3A,D1,D2:Array[0..1000005] ofLongint;4 Flag:boolean;5prArray[0..Ten] ofLongint;6 functionCheck (x:longint): Boolean;inline;7          begin8Exit (((A[D1[A3]]-A[D2[A4)) <=c) and(x>=m));9          End;Ten begin One readln (n,m,c); A       fori:=1  toN Doread (a[i]); - Readln; -flag:=false; thed1[1]:=1;d 2[1]:=1; a3:=1; a1:=1; a4:=1; a2:=1; -      ifCheck1) Then -         begin -Writeln (1); +flag:=true; -         End; +       fori:=2  toN Do A          begin at                while(d1[a3]+m) <=i DoInc (A3); -                while(A3&LT;=A1) and(A[d1[a1]]<=a[i]) DoDec (a1); -Inc (A1);d 1[a1]:=i; -                while(d2[a4]+m) <=i DoInc (A4); -                while(A4&LT;=A2) and(A[d2[a2]]>=a[i]) DoDec (a2); -Inc (A2);d 2[a2]:=i; in               ifCheck (i) Then -                  begin toWriteln (i-m+1); +flag:=true; -                  End; the          End; *      if  not(flag) ThenWriteln ('NONE'); $ Readln;Panax Notoginseng End.

1342: [Baltic2007]sound mute problem

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.