fork download
  1. #include <bits/stdc++.h>
  2. #include <algorithm>
  3. using namespace std;
  4. int main() {
  5. int t = 0, n = 0, k = 0,i=0,value = 0;
  6. scanf("%d", &t);
  7. while(t--){
  8. priority_queue < int > down;
  9. priority_queue <int, vector<int>, greater<int> > up;
  10. scanf("%d%d",&k,&n);
  11. for(i = 1;i <= n;i++){
  12. scanf("%d",&value);
  13. if(i < k){
  14. up.push(value);
  15. printf("-1\n");
  16. }
  17. else if(i == k){
  18. up.push(value);
  19. printf("%d\n",up.top());
  20. }
  21. else{
  22. down.push(value);
  23. if(up.top() < down.top()){
  24. int uptop = up.top();
  25. up.pop();
  26. up.push(down.top());
  27. down.pop();
  28. down.push(uptop);
  29. }
  30. printf("%d\n",up.top());
  31. }
  32. }
  33.  
  34. }
  35.  
  36. return 0;
  37. }
Success #stdin #stdout 0s 4288KB
stdin
Standard input is empty
stdout
Standard output is empty