fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define pb push_back
  5. #define nl '\n'
  6. #define py cout << "YES\n"
  7. #define pn cout << "NO\n"
  8. #define no_dup s.erase(unique(s.begin(), s.end()), s.end());
  9. const double eps = 1e-7;
  10.  
  11. void fastio() {
  12. ios_base::sync_with_stdio(false);
  13. cin.tie(nullptr);
  14. cout.tie(nullptr);
  15. }
  16.  
  17. void solve() {
  18. ll n,m,k;
  19. cin >> n >> m >> k;
  20. //min heap
  21. priority_queue<ll,vector<ll>,greater<ll>>pq;
  22. vector<ll>v;
  23. int cnt =0;
  24. for(int i=0;i<n;i++){
  25. ll x; cin >> x;
  26. pq.push(x);
  27. cnt++;
  28. if(cnt ==m){
  29. v.pb(pq.top());
  30. pq.pop();
  31. cnt--;
  32. }
  33. }
  34.  
  35. while(!pq.empty()){
  36. v.pb(pq.top());pq.pop();
  37. }
  38. cout <<v[k-1]<<nl;
  39. }
  40.  
  41.  
  42. int main() {
  43. fastio();
  44. int t = 1;
  45. cin >> t;
  46. while (t--)
  47. solve();
  48. return 0;
  49. }
Success #stdin #stdout 0.01s 5316KB
stdin
1
6 3 4
1 2 4 7 6 3
stdout
3