杭电oj 1003 wrong answer(待改正)需要极端数据测试
#include <stdio.h>
#include <stdlib.h>
int main(){
int time;
int n;
int start,end;
int sum;
int a[100001];
int startsum,endsum;
//参数
int i,j,x;
scanf("%d",&time);
for(i=1;i<=time;i++){
scanf("%d",&n);
for(j=0;j<n;j++)
scanf("%d",&a[j]);
start=0;
end=j-1;
startsum=0;
endsum=0;
for(x=start,j=end;x<j;x++,j--){
startsum+=a[x];
endsum+=a[j];
if(startsum<0){
start=x+1;
startsum=0;
}
if(endsum<0){
end=j-1;
endsum=0;
}
}
sum=0;
if(start==end)
sum=a[start];
else
for(j=start;j<=end;j++){
sum+=a[j];
}
printf("Case %d:\n",i);
printf("%d %d %d",sum,start+1,end+1);
if(i!=time)
printf("\n\n");
}system("pause");
return 0;
}