标签:
Description
Input
Output
Sample Input
Sample Output
#include<iostream> #include<algorithm> using namespace std; class M{ public: int a,b,sum; }; int x[100002]; int main(){ int t;cin>>t; for(int k=1;k<=t;k++){ if(k!=1)cout<<endl; int n;cin>>n; M t; t.a=1; t.b=1; t.sum=-1000; int ta=1; int sum=0; for(int i=1;i<=n;i++){ cin>>x[i]; sum+=x[i]; if(sum>t.sum){ t.a=ta; t.b=i; t.sum=sum; } if(sum<0){ sum=0; ta=i+1; } } cout<<"Case "<<k<<":"<<endl; cout<<t.sum<<" "<<t.a<<" "<<t.b<<endl; } return 0; }
标签:
原文地址:http://www.cnblogs.com/demodemo/p/4731103.html