标签:
1 var 2 a3,a4,a1,a2,i,j,k,l,m,n,c:longint; 3 a,d1,d2:array[0..1000005] of longint; 4 flag:boolean; 5 pr:array[0..10] of longint; 6 function check(x:longint):boolean;inline; 7 begin 8 exit(((a[d1[a3]]-a[d2[a4]])<=c) and (x>=m)); 9 end; 10 begin 11 readln(n,m,c); 12 for i:=1 to n do read(a[i]); 13 readln; 14 flag:=false; 15 d1[1]:=1;d2[1]:=1;a3:=1;a1:=1;a4:=1;a2:=1; 16 if check(1) then 17 begin 18 writeln(1); 19 flag:=true; 20 end; 21 for i:=2 to n do 22 begin 23 while (d1[a3]+m)<=i do inc(a3); 24 while (a3<=a1) and (a[d1[a1]]<=a[i]) do dec(a1); 25 inc(a1);d1[a1]:=i; 26 while (d2[a4]+m)<=i do inc(a4); 27 while (a4<=a2) and (a[d2[a2]]>=a[i]) do dec(a2); 28 inc(a2);d2[a2]:=i; 29 if check(i) then 30 begin 31 writeln(i-m+1); 32 flag:=true; 33 end; 34 end; 35 if not(flag) then writeln(‘NONE‘); 36 readln; 37 end.
标签:
原文地址:http://www.cnblogs.com/HansBug/p/4392906.html