//Accepted 19324K 8610MS G++ //系统merge Accepted 16820K 6391MS G++ #include //#include #include #include #include using namespace std; const int N = 200020; int a[N]; int n, m, k; int solve() { int i, j; long long ans = 0; int num = 0; j = 0; for(i = 1; i <= n; i++) { while(num < k && j <= n) { j++; if(a[j] >= m) num++; } if(num < k) break; ans += n-j+1; if(a[i] >= m) num--; } printf("%I64d\n", ans); return 0; } int main(void) { int T; scanf("%d", &T); while(T--) { scanf("%d%d%d", &n, &m, &k); for(int i = 1; i <= n; i++) scanf("%d", &a[i]); solve(); } return 0; }