Hdu 1003 Max Sum

#include <stdio.h>
int
a,b[100001],sum;
int
main()
{

    int
t,i,n,j,k,a1,b1,max;
    scanf("%d",&t);
    for
(j=1;j<=t;j++)
    {

        scanf("%d",&n);
        max=-9999;sum=0;
        for
(i=k=1;i<=n;i++)
        {

            scanf("%d",&a); sum+=a;
                if
(max<sum)
                {

                    max=sum;
                    b1=i;a1=k;
                }

                if
(sum<0)
                {
sum=0;
                k=i+1;
                }       
        }
       
        printf("Case %d:\n",j);
        printf("%d %d %d\n",max,a1,b1);       
        if
(j!=t)printf("\n");
    }

    return
0;
}

posted @ 2010-09-08 22:14  CoderZhuang  阅读(112)  评论(0编辑  收藏  举报