请各位大神帮小弟我看一下为什么杭电ACM第三题提交后出现Wrong Answer

请各位大神帮我看一下为什么杭电ACM第三题提交后出现Wrong Answer
子序列最大和(杭电acm1003) 
分类: ACM 2012-03-25 21:50 34人阅读 评论(1) 收藏 举报 
Max Sum
Problem Description
Given a sequence a[1],a[2],a[3]......a[n], your job is to calculate the max sum of a sub-sequence. For example, given (6,-1,5,4,-7), the max sum in this sequence is 6 + (-1) + 5 + 4 = 14.



Input
The first line of the input contains an integer T(1<=T<=20) which means the number of test cases. Then T lines follow, each line starts with a number N(1<=N<=100000), then N integers followed(all the integers are between -1000 and 1000).



Output
For each test case, you should output two lines. The first line is "Case #:", # means the number of the test case. The second line contains three integers, the Max Sum in the sequence, the start position of the sub-sequence, the end position of the sub-sequence. If there are more than one result, output the first one. Output a blank line between two cases.



Sample Input
2
5 6 -1 5 4 -7
7 0 6 -1 1 -6 7 -5

Sample Output
Case 1:
14 1 4

Case 2:
7 1 6


#include<iostream>
using namespace std;

void maxsubsum(int * num,int length)
{
int max,sum=0,i,j,start1=0,start2=0,end;
max=num[0];
for(i=0;i<length;i++)
{
sum+=num[i];
if(max<sum)
{
max=sum;
start1=start2;
end=i;
}
if(sum<0)
{
sum=0;
start2=i+1;
}

}
cout<<max<<" "<<start1+1<<" "<<end+1<<endl;

}
int main()
{
int casenumber;
int number;
int integer;
cin>>casenumber;
if(casenumber<1||casenumber>20)
{
cout<<"There is something wrong for your input!!";
exit(0);
}
int ** num = new int *[casenumber];
int * length = new int[casenumber];
for(int i=0;i<casenumber;i++)
{
cin>>number;
if(number>=1&&number<=100000)
{
num[i]=new int[number];
length[i]=number;
}
for(int j=0;j<number;j++)
{
cin>>integer;
if(integer<-1000||integer>1000)
{
cout<<"the integer you input is wrong!!";
continue;
}
num[i][j]=integer;

}
cout<<endl;
}
for(int j=0;j<casenumber;j++)
{
cout<<"case"<<j+1<<":"<<endl;
maxsubsum(num[j],length[j]);
if(j!=casenumber-1)
cout<<endl;
}
}


我不知道
------解决方案--------------------
仅仅用一个循环就求出最大子列是不可能的. 
例如数列: 6, -1, -7, 4.