/* 最大子段和的动态规划解法1; 2000ms */ #include <iostream> using namespace std; int sums(int i,int j); int deal(short a[],int n); int k = 0; int x = 0; short a[100001]; int main() { int t; int n; scanf("%d",&t); for(int j = 1;j<=t;j++) { scanf("%d",&n); long m = 0; for(int i = 1;i<= n;i++) { cin>>a[i]; m = deal(a,n); } printf("Case "); printf("%d",j); printf(":/n"); printf("%d %d %d/n",m,x,k-1); } return 0; } int deal(short a[],const int n) { long dp[100001]; long f = 0; memset(dp,0,sizeof(int)*100001); for(int i = 1;i<=n;i++) { for(int j = i;j<=n;j++) { f = sums(i,j); if(f>dp[i]) dp[i] = f; } } int max = 0; for(int i = 1;i<= n;i++) if(max<dp[i]) { max = dp[i]; x= i; } long mark = dp[x]; for(k = x;k<=n;k++) { if(mark== 0) break; mark-=a[k]; } return max; } int sums(int i,int j) { int sum = 0; for(int k = i;k<= j;k++) sum+= a[k]; return sum; }