Analysis: becomes 1 greater than or equal to M, otherwise becomes 0, preprocessing prefix and, piece lift point, find first dot prefix and greater than M
Find the first point can be two points to take
#include <cstdio>#include<cstring>#include<cmath>#include<algorithm>using namespaceStd;typedefLong LongLL;Const intN = 2e5+5;intT,n,m,k,a[n],sum[n];intMain () {scanf ("%d",&T); while(t--) {scanf ("%d%d%d",&n,&m,&k); for(intI=1; i<=n;++i) {scanf ("%d",&A[i]); if(a[i]>=m) a[i]=1; Elsea[i]=0; } for(intI=1; i<=n;++i) sum[i]=sum[i-1]+A[i]; LL ret=0; for(intI=1; i<=n;++i) { if(n-i+1<K) Break; if(sum[n]-sum[i-1]<K) Break; intl=i+k-1, r=N; while(l<R) { intMid= (l+r) >>1; if(sum[mid]-sum[i-1]>=K) r=mid; ElseL=mid+1; } inttmp= (l+r) >>1; RET+ = (n-tmp+1); } printf ("%i64d\n", ret); } return 0;}
View Code
HDU5806 nanoape Loves Sequenceⅱ (bestcoder Round #86 C) Two minutes