#include<iostream>
using namespace std;
int main()
{
int test, num;
int a[100000];
cin >> test;
if (test >= 1 && test <= 20)
{
for (int i = 0; i < test; i++)
{
int k_start, k_end, k_start1 = 0;//注意变量位置,不然下一次测试会带着上一次的结果
int max = -1000, sum = 0;
cin >> num;
if (num >= 1 && num <= 100000)
{
for (int j = 0; j < num; j++)
{
cin >> a[j];
sum = sum + a[j];
if (max < sum)
{
max = sum;
k_end = j;
k_start = k_start1;
}
if (sum < 0)
{
k_start1 = j + 1;
sum = 0;//一定把和也清零,因为前面的是负数,都舍弃了
}
}
}
cout << "Case " << i + 1 << ":" << endl;
cout << max << " " << k_start + 1 << " " << k_end + 1 << endl;
if (i < test - 1)
{
cout << endl;
}
}
}
return 0;
}
09-18
1161
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
08-15