标签:its strong hdu acm mes name include scan 连续
题目地址:最大连续子序列
#include <bits/stdc++.h> using namespace std; int a[10000+1024]; int main() { int k; while(scanf("%d",&k)&&k){ for(int i=0;i<k;++i){ scanf("%d",a+i); } int maxsum=0x80000000,cursum=0; int l=0,r=0,c_l=0,c_r=0; for(int i=0;i<k;++i){ cursum+=a[i]; c_r=i; if(maxsum<cursum){ maxsum=cursum; l=c_l; r=c_r; } if(cursum<0){ cursum=0; c_l=c_r=i+1; } } if(maxsum<0) maxsum=0,l=0,r=k-1; printf("%d %d %d\n",maxsum,a[l],a[r]); } return 0; }
标签:its strong hdu acm mes name include scan 连续
原文地址:https://www.cnblogs.com/zil17/p/8886420.html