关于杭电Oj1003题的一个解法
#include <iostream>
using namespace std;
int main()
{
int max,start,end,temp,n,k,t,a;
cin>>t;
for(int i = 1; i <= t; i++)
{
cin>>n;
max=-9999;
temp=0;
start=1;
end=1;
k=1;
for(int j = 1;j <= n;j++)
{
cin>>a;
temp += a;
if(temp > max)
{
max = temp;
start = k;
end = j;
}
if(temp < 0)
{
temp = 0;
k = j+1;
}
}
if(i != 1)
cout<<endl;
cout<<"Case "<<i<<":"<<endl;
cout<<max<<" "<<start<<" "<<end<<endl;
}
}