Prepare for a future No.3 how many of the consecutive substrings meet the number of k greater than or equal to M

Source: Internet
Author: User

The world gave me the eyes to find the light but let me grope in the dark I'm not a bad guy, but I can't be a good guy.

Xu Yu A variety of bored, then turned up a math book looked up the series

A series of length n, he wrote down a number m, he wanted to know how many intervals in the sequence of the number of K-large numbers not less than m, of course, first of all, the interval must have at least K number

Input

The first number indicates a T group case

Then there's n,m,k.

Finally there is an array of length n (0<n<10000) (k>0) (0<m<n)

Output

For each set of data output a single number represents the answer.

#include <cstdio>#include<cstring>#include<queue>#include<vector>#include<algorithm>#include<iostream>#include<math.h>using namespacestd;#defineLL Long Long#defineINF 0x3f3f3f3f#defineN 10009intA[n],q[n],qq[n];intMain () {intt,n,m,k; scanf ("%d",&T);  while(t--) {scanf ("%d%d%d",&n,&m,&k);  for(intI=1; i<=n;i++) scanf ("%d",&A[i]); intans=0, sum=0;  for(intI=1; i<=n;i++)        {            if(a[i]>=m) {Q[i]=q[i-1]+1; qq[++ans]=i; }            ElseQ[i]=q[i-1]; if(q[i]>=k) Sum+=qq[q[i]-k+1]; } printf ("%d\n", sum); }    return 0;}

Prepare for a future No.3 how many of the consecutive substrings meet the number of k greater than or equal to M

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.