杭电1003

#include<iostream>
using namespace std;
int main()
{
    int t, n, z, i, x, begin, last, temp, _case = 1;
    cin>>t;
    while(t--)
    {
        begin = 1, last = 1, temp = 1;
        int thissum = 0, maxsum = -1001;
        cin>>n;
        for(i = 1; i <= n; i++)
        {
            cin>>x;
            thissum += x;
            if(thissum > maxsum)
            {
                maxsum = thissum;
                begin = temp;
                last  = i;
            }
            if(thissum < 0)
            {
                thissum = 0;
                temp = i+1;
            }
        }
        printf("Case %d:\n%d %d %d\n",_case++,maxsum,begin, last);
        if(t)
        printf("\n");
    }
    return 0;
}

全部评论

相关推荐

11-11 16:40
已编辑
门头沟学院 人工智能
不知道怎么取名字_:这个有点不合理了,相当于已经毕业了,但还是没转正,这不就是白嫖
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务