首页 > 其他 > 详细

杭电oj 1003 wrong answer(待改正)需要极端数据测试

时间:2015-03-29 18:00:09      阅读:228      评论:0      收藏:0      [点我收藏+]

#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;

}

杭电oj 1003 wrong answer(待改正)需要极端数据测试

原文:http://www.cnblogs.com/ganeveryday/p/4375941.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!