Cod sursa(job #1192107)
| Utilizator | Data | 28 mai 2014 20:24:49 | |
|---|---|---|---|
| Problema | Subsecventa de suma maxima | Scor | 55 |
| Compilator | fpc | Status | done |
| Runda | Arhiva educationala | Marime | 0.61 kb |
program mire;
var n,i,en,b,x:longint;
s:int64;
best:array[1..6000000] of longint;
f,g:text;
begin
assign(f,'ssm.in'); reset(f);
assign(g,'ssm.out'); rewrite(g);
readln(f,n);
read(f,x);
s:=x;
best[1]:=x;
for i:=2 to n do
begin
read(f,x);
best[i]:=x;
if best[i]<(best[i-1]+x) then
begin
best[i]:=best[i-1]+x;
end
else
b:=i;
if s<best[i] then
begin
s:=best[i];
en:=i;
end;
end;
writeln(g,s,' ',b,' ',en);
close(f);
close(g);
end.
