http://acm.hdu.edu.cn/showproblem.php?pid=1003

靠,总算过了,不解释

View Code
#include <stdio.h>
#include <stdlib.h>

int a[110000];
int main()
{
    int t,n;
    int i,f;
    int max,now;
    int start,end;
    int temp;
    int nCase=1;
    scanf("%d",&t);
    f=0;
    while(t--)
    {
        scanf("%d",&n);
        scanf("%d",a+0);
        max=now=a[0];
        start=end=temp=0;
        for(i=1;i<n;i++)
        {
            scanf("%d",a+i);
            if(now+a[i]<a[i])
            {
                now=a[i];
                temp=i;
            }
            else
                now+=a[i];
            if(now>max){
                max=now;
                start=temp;
                end=i;
            }    
        }
        if(f)
            putchar('\n');
        printf("Case %d:\n",nCase++);
        printf("%d %d %d\n",max,start+1,end+1);
        f=1;
    }
    return 0;
}