Cod sursa(job #769449)
Utilizator | Data | 19 iulie 2012 14:18:27 | |
---|---|---|---|
Problema | Subsecventa de suma maxima | Scor | 65 |
Compilator | fpc | Status | done |
Runda | Arhiva educationala | Marime | 0.57 kb |
var n,s,i,d:longint; a:array[1..2,1..6000000]of longint;
begin
assign(input,'ssm.in'); reset(input);
read(n);
for i:=1 to n do begin
read(a[1,i]);
if i=1 then begin a[2,i]:=1; d:=1 end
else
if a[1,i]>=a[1,i-1]+a[1,i] then a[2,i]:=i
else begin
a[1,i]:=a[1,i]+a[1,i-1];
a[2,i]:=a[2,i-1]
end;
if a[1,i]>a[1,d] then
d:=i
else
if a[1,i]=a[1,d] then
if a[2,i]=d then
if i-a[2,i]<d-a[2,d] then d:=i;
end;
assign(output,'ssm.out'); rewrite(output);
writeln(a[1,d],' ',a[2,d],' ',d);
close(output);
end.