Max Sum
http://acm.hdu.edu.cn/showproblem.php?pid=1003
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+7;
const int inf=0x8fffffff;
int main()
{
int i,j,k,m,n,t,tt=0;
cin>>t;
while(t--)
{
int tmp,a,from,to,c,now,ans;
cin>>n>>tmp;
from=to=a=1;
ans=now=tmp;
for(i=2;i<=n;i++)
{
cin>>tmp;
if(now<0){now=tmp;a=i;}
else now+=tmp;
if(now>ans)
{
ans=now;from=a;to=i;
}
}
cout<<"Case "<<++tt<<":"<<endl;
cout<<ans<<" "<<from<<" "<<to<<endl;
if(t!=0) cout<<endl;
}
return 0;
}
转载请注明原文地址: https://ju.6miu.com/read-1293377.html