Pagini recente » Cod sursa (job #2022876) | Cod sursa (job #2450566) | Cod sursa (job #1823924) | Cod sursa (job #2481789) | Cod sursa (job #1122016)
var
f,g:text;
cbs,ccap,coada,cap,n,i,bs:longint;
a,t:array[0..6000000] of integer;
begin
assign(f,'ssm.in');reset(f);
assign(g,'ssm.out');rewrite(g);
readln(f,n);
for i:=1 to n do read(f,a[i]);
bs:=a[1];
for i:=1 to n do
begin
t[i]:=a[i];
if t[i] < t[i-1]+a[i] then t[i]:=t[i-1]+a[i];
if t[i]>bs then
begin
bs:=t[i];
cap:=i;
end;
end;
cbs:=bs;
ccap:=cap;
while cbs<>0 do
begin
cbs:=cbs-a[ccap];
dec(ccap);
end;
writeln(g,bs,' ',ccap+1,' ',cap);
close(g);
end.