Accepted
/usr/bin/ld.bfd: warning: /out/link.res contains output sections; did you forget -T?
代码
var n,i,max,ans,t,s,sum:longint;
a,w:array[0..2000]of longint;
begin
readln(n);
a[0]:=0;
for i:=1 to n do begin
read(t);
a[i]:=t+a[i-1];
w[i]:=t;
end;
max:=-maxlongint;
for s:=1 to n do begin
ans:=0;
sum:=0;
for i:=s to n do begin
ans:=ans+a[i]-a[i-1]+sum;
sum:=sum+w[i];
if (ans>max) then max:=ans;
end;
end;
writeln(max);
close(input);
close(output);
end.