标签:contest ref href while ++ class int col for
最大子序和
1 FOR(i,1,n) sum[i]=sum[i-1]+a[i]; 2 int l=1,r=1; 3 q[1]=0; 4 FOR(i,1,n) 5 { 6 while(l<=r&&q[l]<i-m) l++; 7 ans=max(ans,sum[i]-sum[q[l]]); 8 while(l<=r&&sum[q[r]]>=sum[i]) r--; 9 q[++r]=i; 10 }
标签:contest ref href while ++ class int col for
原文地址:https://www.cnblogs.com/universeplayer/p/10655762.html