# 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;
}

08-06 535

05-11 143

09-12 105

08-07 261

08-07 443

08-07 93

08-06 192

08-07 141

08-08 350

08-08 117