1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 5 using namespace std; 6 7 long long dp[100010]; 8 int start[100010]; 9 int arr[100010]; 10 11 int main() 12 { 13 int T; 14 scanf("%d",&T); 15 for(int l=1;l<=T;l++) 16 { 17 if(l>1) 18 cout<<endl; 19 int n; 20 scanf("%d",&n); 21 for(int i=1;i<=n;i++) 22 scanf("%d",&arr[i]); 23 for(int i=1;i<=n;i++) 24 start[i]=i; 25 memset(dp,0,sizeof(dp)); 26 for(int i=1;i<=n;i++) 27 { 28 if(dp[i-1]+arr[i]>(long long)arr[i]) 29 { 30 start[i]=start[i-1]; 31 dp[i]=dp[i-1]+arr[i]; 32 } 33 else 34 dp[i]=arr[i]; 35 } 36 long long ans=-(1<<29); 37 int se=0; 38 for(int i=1;i<=n;i++) 39 { 40 if(dp[i]>ans) 41 { 42 se=i; 43 ans=dp[i]; 44 } 45 } 46 cout<<"Case "<<l<<":"<<endl; 47 cout<<ans<<" "<<start[se]<<" "<<se<<endl; 48 } 49 return 0; 50 }
时间: 2024-10-18 15:38:43