Sample Output
21
var a,f:array[1..500]of longint; i,j,n,max:longint;begin max:=-maxlongint; read(n); for i:=1 to n do read(a[i]); if a[1]>0 then f[1]:=a[1]; for i:=2 to n do if f[i-1]+a[i]>0 then f[i]:=f[i-1]+a[i]; for i:=1 to n do if f[i]>=max then max:=f[i]; write(max);end.
新闻热点
疑难解答