Pagini recente » Cod sursa (job #3174942) | Cod sursa (job #2934789) | Cod sursa (job #2903405) | Cod sursa (job #1171761) | Cod sursa (job #93823)
Cod sursa(job #93823)
type sir=array[1..500000]of integer;
var s:sir;
n,k,min,sf:integer;
procedure citire;
var i,j,pmin:integer;
begin
assign(input,'secventa.in');
reset(input);
readln(n,k);
min:=-maxint;
pmin:=1;
sf:=1;
for i:=1 to n do
begin
read(s[i]);
if pmin>i-k then
begin
if s[i]<s[pmin] then
pmin:=i
end
else
begin
pmin:=i;
for j:=1 to k-1 do
if s[pmin]>s[i-j] then
pmin:=i-j;
end;
if s[pmin]>min then
begin
min:=s[pmin];
sf:=i;
end;
end;
close(input);
assign(output,'secventa.out');
rewrite(output);
writeln(sf-k+1,' ',sf,' ',min);
close(output);
end;
begin
citire;
end.