![ContractedBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![ExpandedBlockStart.gif](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
#include
"
iostream
"
using namespace std;
int main()
{
int t;
int n,a;
int i,j = 0 ,k;
cin >> t;
while (t -- )
{
cin >> n;
int sum = 0 ,Max =- 99999999 ;
int start = 0 ,end = 0 ;
k = 0 ;
for (i = 0 ;i < n;i ++ )
{
cin >> a;
sum += a;
if (sum > Max)
{
Max = sum;
start = k + 1 ;
end = i + 1 ;
}
if (sum < 0 )
{
sum = 0 ;
k = i + 1 ;
}
}
cout << " Case " <<++ j << " : " << endl;
cout << Max << " " << start << " " << end << endl;
if (t > 0 ) cout << endl;
}
return 0 ;
}
using namespace std;
int main()
{
int t;
int n,a;
int i,j = 0 ,k;
cin >> t;
while (t -- )
{
cin >> n;
int sum = 0 ,Max =- 99999999 ;
int start = 0 ,end = 0 ;
k = 0 ;
for (i = 0 ;i < n;i ++ )
{
cin >> a;
sum += a;
if (sum > Max)
{
Max = sum;
start = k + 1 ;
end = i + 1 ;
}
if (sum < 0 )
{
sum = 0 ;
k = i + 1 ;
}
}
cout << " Case " <<++ j << " : " << endl;
cout << Max << " " << start << " " << end << endl;
if (t > 0 ) cout << endl;
}
return 0 ;
}