You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
690 B
C++
30 lines
690 B
C++
#include <cstdio>
|
|
#include <cstring>
|
|
#include <algorithm>
|
|
using namespace std;
|
|
int a[100010],f[100010];
|
|
int main()
|
|
{
|
|
int T,n;
|
|
scanf("%d",&T);
|
|
for(int t=1; t<=T; t++)
|
|
{
|
|
memset(a,0,sizeof(a));
|
|
memset(f,0,sizeof(f));
|
|
scanf("%d",&n);
|
|
for(int i=1; i<=n; i++)
|
|
scanf("%d",a+i);
|
|
int sum=0,l=1,r=1;
|
|
for(int i=1; i<=n; i++)
|
|
f[i]=max(f[i-1]+a[i],a[i]);
|
|
r=max_element(f+1,f+n+1)-f;
|
|
for(int i=r; i; i--)
|
|
if((sum+=a[i])==f[r])
|
|
l=i;
|
|
printf("Case %d:\n%d %d %d\n",t,f[r],l,r);
|
|
if(T-t)
|
|
puts("");
|
|
}
|
|
return 0;
|
|
}
|