Pagini recente » Istoria paginii runda/simulare_oji_2023_clasa_9_16_martie | Cod sursa (job #1259196) | Cod sursa (job #1013614) | Cod sursa (job #2802992) | Cod sursa (job #431479)
Cod sursa(job #431479)
Program secventa;
{type stack=array [1..500000] of integer; }
var f:text;
n,k,i,ke,ve,p1,p2,p,l:longint;
a:array [1..500000] of integer;
o,max:integer;
function min():integer;
var m,e:longint;
begin
min:=a[p];
inc(p);
e:=p;
for m:=e to l do
if a[m]<min
then min:=a[m];
dec(p);
end;
begin
assign(f,'secventa.in');
reset(f);
read(f,n,k);
for i:=1 to k do
read(f,a[i]);
l:=k;
p:=1;
max:=min();
p1:=1;
p2:=l;
ke:=a[p];
ve:=a[l];
{}
while l<n do
begin
inc(p);inc(l);
read(f,a[l]);
o:=min();
if o>max
then
begin
max:=o;
p1:=l-k+1;
p2:=l;
ke:=a[p];
ve:=a[l];
end
else
if o=max
then
if (a[p]<ke)
then
begin
max:=o;
p1:=l-k+1;
p2:=l;
ke:=a[p];
ve:=a[l];
end
else
if ((a[p]=ke) and (a[l]<ve))
then
begin
max:=o;
p1:=l-k+1;
p2:=l;
ke:=a[p];
ve:=a[l];
end;
end;
close(f);
assign(f,'secventa.out');
rewrite(f);
write(p1,' ',p2,' ',max);
close(f);
end.