lina_os

Untitled

Apr 2nd, 2025
16
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define ll long long
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7. ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  8. int t;
  9. cin >> t;
  10. while (t--) {
  11. int n, m, k;
  12. cin >> n >> m >> k;
  13. k--;
  14. vector<int>v(n);
  15. for (int i=0; i<n; i++) {
  16. cin >> v[i];
  17. }
  18. vector<int>ans;
  19. multiset<int>s (v.begin(), v.begin()+m);
  20. ans.push_back(*s.begin());
  21. for (int i=0;i<n-m; i++) {
  22. s.erase(s.find(v[i]));
  23. s.insert(v[i+m]);
  24. ans.push_back(*s.begin());
  25. }
  26. ans.pop_back();
  27. ans.insert(ans.end(), s.begin(), s.end());
  28. cout << ans[k] << endl;
  29. }
  30. return 0;
  31. }
  32.  
  33. /*
  34. * 3 1 2 6
  35. * 1 2 3 4 5 6
  36. * 1 7 8
  37. */
Advertisement
Add Comment
Please, Sign In to add comment