hdu_1003 Max

//格式最坑的题库- -

#include<bits/stdc++.h>
using namespace std; int q,f,l,sum,a[100010],maxn,mayf=1; int main(){ scanf("%d",&q); for(int i=1;i<=q;i++){ memset(a,0,sizeof(a)); maxn=-(1<<30); sum=f=l=0; mayf=1; printf("Case %d:\n",i); int n; scanf("%d",&n); for(int i=1;i<=n;i++){ scanf("%d",&a[i]); sum+=a[i]; if(sum>maxn){maxn=sum; l=i; f=mayf;} if(sum<0){sum=0; mayf=i+1;} } cout<<maxn<<" "<<f<<" "<<l<<endl; if(i!=q)puts(""); } return 0; }


posted @ 2017-06-23 12:32  wqtnb_tql_qwq_%%%  阅读(115)  评论(0编辑  收藏  举报