ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
~~~ #include <iostream> using namespace std; int main() { int T,N,i,j,a[100001],count=0; cin>>T; for (j=0;j<T;j++) { cin>>N; for (i=0;i<N;i++) cin>>a[i]; int maxSum=a[0]; int sum=0,l=0,r=0,temp=0; for (i=0;i<N;i++) { sum=sum+a[i]; if(sum>maxSum) { maxSum=sum; l=temp; r=i; } if(sum<0) { sum=0; temp=i+1; } } count++; cout<<"Case "<<count<<":"<<endl; cout<<maxSum<<" "<<l+1<<" "<<r+1<<endl; if(j<T-1) cout<<endl; } return 0; } ~~~