题目链接:HDU5806
题意:找出有多少个区间中第k大数不小于m.
分析:用尺取法可以搞定,CF以前有一道类似的题目.
#include<cstdio>
using namespace std;
typedef long long ll;
#define d\n I64d\n
int T,n,m,K,num,r,a[];
ll ans;
int main()
{
scanf("%d",&T);
while (T--)
{
scanf("%d%d%d",&n,&m,&K);
for (int i=;i<=n;i++) scanf("%d",&a[i]);
num=;r=;ans=;
for (int i=;i<=n;i++)
{
while (num<K&&r<n){r++;num+=(a[r]>=m);}
if (num<K) break;
ans+=n-r+;
num-=(a[i]>=m);
}
printf("%d",ans);
}
}