Pagini recente » Cod sursa (job #3039172) | Cod sursa (job #2595553) | Cod sursa (job #1784653) | Cod sursa (job #2566761) | Cod sursa (job #872958)
Cod sursa(job #872958)
program info;
type sir=record
ind:longint;
s:integer;
end;
var v,sum:array[1..6000000] of integer;
i,j,indice:longint;
suma,max,maxbest:integer;
n,primu,second:longint;
f,g:text;
best:array[1..6000000] of sir;
begin
assign(f,'ssm.in'); reset(f);
assign(g,'ssm.out'); rewrite(g);
suma:=0;
readln(f,n);
read(f,v[1]);
sum[1]:=v[1];
for i:=2 to n do
begin
read(f,v[i]);
sum[i]:=sum[i-1]+v[i];
end;
maxbest:=-maxint;
for i:=1 to n do
begin
max:=-maxint;
for j:=2 to i do
if sum[i]-sum[j-1]>max then
begin
max:=sum[i]-sum[j-1];
indice:=j;
end;
best[i].s:=max;
best[i].ind:=indice;
if maxbest<best[i].s then
begin
maxbest:=best[i].s;
primu:=i;
second:=best[i].ind;
end;
end;
write(g,best[primu].s,' ',second,' ',primu);
close(f);
close(g);
end.