hdu 1003 MAX SUM(最大连续子序列和)

状态转移方程:sum[i] = max{sum[i-1]+a[i],a[i]}.

#include 
int main()
{
    int n, i, t, k, cc, sum;
    int a,b, A, B;
    scanf("%d", &t);
    for(cc=1; cc<=t; cc++)
    {
        scanf("%d", &n);
        int max=-1001;
        sum=-11001;
        for(i=1; i<=n; i++)
        {
            scanf("%d", &k);
            if(sum+kmax)
            {
                max=sum; A=a;B=b;
            }
        }
        printf("Case %d:\n", cc);
        printf("%d %d %d\n", max, A,B);
        if(cc



你可能感兴趣的:(DP)