Description 求最大連續子序列的和Input 第一行輸入n(n<=500),第二行為n個以空格分開的整數(-1000到1000之間);Output 該序列中最大的連續子序列的和Sample Input 6 1 2 -5 6 7 8Sample Output 21題解:這道題用動態規劃。 if t>a[i-1]+t then a[i]:=t else a[i]:=a[i-1]+t;var a:array[-1..1000] of longint; max,n,t,i:longint;begin readln(n); for i:=1 to n do begin read(t); if t>a[i-1]+t then a[i]:=t else a[i]:=a[i-1]+t; end; for i:=1 to n do if a[i]>max then max:=a[i]; writeln(max);end.