# NanoApe Loves Sequence Ⅱ

In math class, NanoApe picked up sequences once again. He wrote down a sequence with   numbers and a number   on the paper.

Now he wants to know the number of continous subsequences of the sequence in such a manner that the  -th largest number in the subsequence is no less than  .

Note : The length of the subsequence must be no less than  .

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <string>
#include <cstring>
#include <functional>
#include <cmath>
#include <cctype>
#include <cfloat>
#include <climits>
#include <complex>
#include <deque>
#include <list>
#include <set>
#include <utility>
using namespace std;

int pre[200010];
__int64 ans;
int n,m,k,temp;

int main()
{
//freopen("in.txt","r",stdin);
int T;
scanf("%d",&T);
while(T--)
{
ans=0;
scanf("%d %d %d",&n,&m,&k);
for(int i=1;i<=n;i++){
scanf("%d",&temp);
if(temp>=m)
pre[i]=pre[i-1]+1;
else
pre[i]=pre[i-1];
}
int l,r;
l=0,r=1;
for(;l<n;l++){
while(pre[r]-pre[l]<k&&r<=n)
r++;
if(pre[r]-pre[l]<k)break;
ans+=n-r+1;
}
printf("%I64d\n",ans);
}
return 0;
}

• 本文已收录于以下专栏：

## NanoApe Loves Sequence Ⅱ(尺取法）

NanoApe Loves Sequence Ⅱ    Accepts: 374    Submissions: 946  Time Limit: 4000/2000 MS (Java/...
• qaz135135135
• 2016年09月12日 19:38
• 91

## hdu NanoApe Loves Sequence Ⅱ

NanoApe Loves Sequence Ⅱ Accepts: 235 Submissions: 396 Time Limit: 4000/2000 MS (Java/Others) Mem...
• u013097262
• 2016年08月06日 20:13
• 479

## hdoj5850 NanoApe Loves Sequence BestCoder Round #86

NanoApe Loves Sequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/131072 K (Jav...
• kyoma
• 2016年08月07日 23:18
• 208

## hdu NanoApe Loves Sequence

Problem Description NanoApe, the Retired Dog, has returned back to prepare for the National Highe...
• maqinyao5566
• 2016年08月08日 13:18
• 134

## NanoApe Loves Sequence

• aaakirito
• 2016年08月08日 16:24
• 323

## HDU5806 NanoApe Loves Sequence Ⅱ

• xiaolonggezte
• 2016年08月07日 16:25
• 126

## hdu NanoApe Loves Sequence

NanoApe Loves Sequence Accepts: 505 Submissions: 1646 Time Limit: 2000/1000 MS (Java/Others...
• u013097262
• 2016年08月06日 20:10
• 515

## hdoj5805 NanoApe Loves Sequence && hdoj 5806 NanoApe Loves Sequence Ⅱ

NanoApe Loves Sequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/131072 K (Java...
• zyf_2014
• 2016年08月06日 22:11
• 266

## [HDU5805]-NanoApe Loves Sequence

NanoApe Loves Sequence    Accepts: 531    Submissions: 2481  Time Limit: 2000/1000 MS (Java/Others)...
• liyongfan152
• 2016年08月08日 10:57
• 106

## hdu5806：NanoApe Loves Sequence Ⅱ

Problem Description NanoApe, the Retired Dog, has returned back to prepare for for the National Hig...
• Davenny
• 2016年08月07日 09:10
• 83

举报原因： 您举报文章：NanoApe Loves Sequence Ⅱ 色情 政治 抄袭 广告 招聘 骂人 其他 (最多只允许输入30个字)