/** 2016 - 08 - 06 晚上 Author: ITAK Motto: 今日的我要超越昨日的我,明日的我要胜过今日的我, 以创作出更好的代码为目标,不断地超越自己。 **/ #include #include #include #include #include #include #include #include #include using namespace std; typedef long long LL; typedef unsigned long long ULL; const int INF = 1e9+5; const int MAXN = 1e6+5; const LL MOD = 1e9+7; const double eps = 1e-7; const double PI = acos(-1); using namespace std; int a[MAXN]; LL sum[MAXN]; int main() { int T, n, m, k; scanf("%d",&T); while(T--) { scanf("%d%d%d",&n,&m,&k); memset(a, 0, sizeof(a)); for(int i=1; i<=n; i++) { LL x; scanf("%I64d",&x); if(x >= m) a[i] = 1; } LL ans = 0; sum[0] = 0; for(int i=1; i<=n; i++) sum[i] = sum[i-1]+a[i]; for(int i=1; i<=n; i++) { if(n-i+1 < k) break; if(sum[n]-sum[i-1] < k) break; int l = i+k-1, r = n; while(l < r) { int mid = (l+r)>>1; if(sum[mid]-sum[i-1] >= k) r = mid; else l = mid+1; } int tp = (l+r)>>1; ans += (n-tp+1); } printf("%I64d\n",ans); } return 0; }