HDU5806 nanoape Loves Sequenceⅱ (bestcoder Round #86 C) Two minutes

Source: Internet
Author: User

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&LT;K) Break; if(sum[n]-sum[i-1]&LT;K) Break; intl=i+k-1, r=N;  while(l<R) {         intMid= (l+r) >>1; if(sum[mid]-sum[i-1]&GT;=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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.