Cod sursa(job #264665)

Utilizator ladyLittle Lady lady Data 22 februarie 2009 16:07:19
Problema Secventa Scor 0
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.46 kb
var a:array[1..500000]of integer;
    n,k,i,s,max,nr:longint;
begin
assign(input,'secventa.in');reset(input);
assign(output,'secventa.out');rewrite(output);
readln(n,k);
for i:=1 to n do
 read(a[i]);
s:=0;
max:=0;
nr:=0;
for i:=1 to n-2 do begin
 s:=a[i]+a[i+1]+a[i+2];
 if s>max then begin
  max:=s; nr:=i; end; end;
if a[nr]>a[nr+2] then
write(a[nr],' ',a[nr+1],' ',a[nr+2])
  else
write(a[nr+2],' ',a[nr+1],' ',a[nr]);
close(input);close(output);
end.