Cod sursa(job #1417464)

Utilizator laura.calimanLaura Caliman laura.caliman Data 10 aprilie 2015 13:17:08
Problema Subsecventa de suma maxima Scor 30
Compilator fpc Status done
Runda Arhiva educationala Marime 0.41 kb
var n,m,s,i,j,x,y:longint;
    a:array[1..6000000] of longint;
    
begin
  assign(input,'ssm.in');
  assign(output,'ssm.out');
  reset(input);
  rewrite(output);
  read(n);
  s:=0;
  for i:=1 to n do begin
    read(m);
    for j:=1 to i do begin
      a[j]:=a[j]+m;
      if a[j]>s then begin
        s:=a[j];
        x:=j;
        y:=i;
      end;
    end;
  end;
  write(s,' ',x,' ',y);
end.