dp入门题。思路就不解释了
#include <iostream>
#include <limits>
using namespace std;
const int INF=numeric_limits<int>::min();
int array[100001];
int main()
{
int t;
cin>>t;
for (int kk=1; kk<=t; ++kk)
{
int n;
cin>>n;
for (int i=0; i<n; ++i)
cin>>array[i];
int maxsum=INF;
int sum=0;
int first=0;
int last=0;
int temp=1;
for (int i=0; i<n; ++i)
{
sum+=array[i];
if (sum>maxsum)
{
maxsum=sum;
first=temp;
last=i+1;
}
if (sum<0)
{
sum=0;
temp=i+2;
}
}
cout<<"Case "<<kk<<":\n";
cout<<maxsum<<" "<<first<<" "<<last;
if (kk!=t)
cout<<endl<<endl;
else
cout<<endl;
}
}