#include #include #include #include #include using namespace std; typedef long long LL; const int MaxN = 2e5; int T, n, m, K; int a[MaxN + 5], pred[MaxN + 5]; LL ans; int main() { scanf("%d", &T); for (int cas = 1; cas <= T; cas++) { scanf("%d%d%d", &n, &m, &K); pred[0] = 0; for (int i = 1; i <= n; i++) { scanf("%d", &a[i]); if (a[i] >= m) pred[i] = pred[i - 1] + 1; else pred[i] = pred[i - 1]; } ans = 0; for (int l = 1; l <= n - K + 1; l++) { int L = l + K - 2, R = n; while (L < R - 1) { int mid = (L + R) >> 1; if (pred[mid] - pred[l - 1] >= K) R = mid; else L = mid; } if (pred[R] - pred[l - 1] < K) continue; //printf("%d : %d\n", R, n - R + 1); ans = ans + (LL)n - R + 1; } printf("%I64d\n", ans); } }