Pagini recente » Cod sursa (job #2882747) | Cod sursa (job #1055926) | Cod sursa (job #660679) | Cod sursa (job #813808) | Cod sursa (job #1179385)
program p1;
var a:array[0..6000000] of longint;
n,i,sum,idx,j,max:longint;
bufin:array[1..1 shl 17] of char;
begin
assign(input,'ssm.in');
reset(input);
assign(output,'ssm.out');
rewrite(output);
settextbuf(input,bufin);
readln(n);
maX:=-1 shl 30;
for i:=1 to n do read(a[i]);
for i:=1 to n do
begin
if sum<0 then begin
sum:=a[i];
idx:=i;
end
else
sum:=sum+a[i];
if sum>max then begin
max:=sum;
j:=i;
end;
end;
writeln(max,' ',idx,' ',j);
close(output);
end.