boolcheck(int x){ int l = 1, r = 0, cnt = 0; longlong sum = 0; while (r <= n) { if (cnt == k) { sum += (n - r + 1LL); cnt -= (a[l++] >= x); } else cnt += (a[++r] >= x); } return sum >= m; }
intmain(){ cin >> t; while (t--) { cin >> n >> k >> m; for (int i = 1; i <= n; i++) cin >> a[i]; int l = 0, r = 1e9 + 7, mid; while (l + 1 < r) { int mid = (l + r) >> 1; if (check(mid)) l = mid; else r = mid; } cout << l << '\n'; } return0; }