当前位置:网站首页>Blue Bridge Cup_ Pick substring_ Combinatorial mathematics_ Multiplication principle/ Ruler method

Blue Bridge Cup_ Pick substring_ Combinatorial mathematics_ Multiplication principle/ Ruler method

2022-06-10 22:45:00 This question AC sleep again

 

//
#include<bits/stdc++.h>
using namespace std;

typedef long long LL;
const int N=2e5+6;
LL in[N],f[N];

int main()
{
    LL n,m,k,i,pos,ans;

    while( cin>>n>>m>>k )
    {
        ans=pos=0;
        for( i=1;i<=n;i++ )
        {
            cin>>in[i];
            if( in[i]<m ) continue;

            f[++pos]=i;                     // ++pos
            if( pos<k ) continue;
                                            // 1
            if( pos==k )    ans+=f[1]*( n-i+1 );
            else            ans+=( f[pos-k+1]-f[pos-k] )*( n-i+1 );
        }                                   // pos-k>=1 ==> ++pos
        cout<<ans<<endl;
    }
    return 0;
}

原网站

版权声明
本文为[This question AC sleep again]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/161/202206101642255067.html