#include<bits/stdc++.h> usingnamespace std; longlong a[500005], k; int n, m; boolC(int hd, int l, int dis) { int i; vector<longlong> pq; for (i = 1; i <= dis; i++) pq.push_back(a[i + l]); sort(pq.begin(), pq.end()); longlong ret = 0; int sum = 0, j = 0; vector<longlong> t; i = hd; while (i <= l && j < pq.size()) { if (pq[j] > a[i]) t.push_back(a[i++]); else t.push_back(pq[j++]); } while (i <= l) t.push_back(a[i++]); while (j < pq.size()) t.push_back(pq[j++]); j = t.size() - 1; i = 0; while (j > i && sum < m) { ret += (t[i] - t[j]) * (t[i] - t[j]); i++; j--; sum++; } return ret <= k; } intmain() { int _, i; scanf("%d", &_); while (_--) { scanf("%d%d%lld", &n, &m, &k); for (i = 1; i <= n; i++) scanf("%lld", &a[i]); int l = 1, dis, res = 0, hd = 1; while (hd <= n) { dis = 1; while (l + dis <= n && C(hd, l, dis)) dis <<= 1; dis >>= 1; if (dis == 0) { res++; l++; hd = l; continue; } vector<longlong> pq; for (i = 1; i <= dis; i++) pq.push_back(a[i + l]); sort(pq.begin(), pq.end()); longlong ret = 0; int sum = 0, j = 0; vector<longlong> t; i = hd; while (i <= l && j < pq.size()) { if (pq[j] > a[i]) t.push_back(a[i++]); else t.push_back(pq[j++]); } while (i <= l) t.push_back(a[i++]); while (j < pq.size()) t.push_back(pq[j++]); for (i = 0; i < t.size(); i++) a[hd + i] = t[i]; l += dis; } printf("%d\n", res); } return0; }