标签:
#include<stdio.h>
int
main() {
int
T;
scanf
(
"%d"
,&T);
for
(
int
i=1;i<=T;i++) {
int
n,num,sum=0,maxn=-1100,maxNum=-1100,maxJ=1,a=1,b=1,c=1,flag=0;
scanf
(
"%d"
,&n);
for
(
int
j=1;j<=n;j++) {
scanf
(
"%d"
,&num);
sum+=num;
if
(sum>maxn) {
maxn=sum;
a=c;
b=j;
}
if
(sum<0) {
sum=0;
c=j+1;
}
if
(num>maxNum) {
maxNum=num;
maxJ=j;
}
if
(num>=0) {
flag=1;
}
}
if
(!flag) {
maxn=maxNum;
a=maxJ;
b=maxJ;
}
if
(i!=1) {
printf
(
"\n"
);
}
printf
(
"Case %d:\n%d %d %d\n"
,i,maxn,a,b);
}
return
0;
}
标签:
原文地址:http://www.cnblogs.com/wuyuanyuan/p/5340926.html