fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main(){
  5. int q,n,r,num;
  6. cin>>q;
  7. while(q--){
  8. cin>>n>>r;
  9. multiset<int> ms;
  10. multiset<int>:: iterator itr;
  11. multiset<int>:: iterator it;
  12. for(int i=0;i<n;i++){
  13. cin>>num;
  14. ms.insert(num);
  15. }
  16. //while(!ms.empty()){
  17. itr=ms.end();
  18. it=ms.begin();
  19. itr--;
  20. int val = *itr;
  21. ms.erase(val);
  22. // for(it=ms.begin();it!=ms.end();it++){
  23. int del=*it;
  24. cout<<del<<" ";
  25. // ms.erase(it);
  26. // if((del-r)>0){
  27. // del-=r;
  28. // ms.insert(del);
  29. // }
  30. // }
  31. cout<<"executed"<<endl;
  32.  
  33. // it++;
  34. cout<<"hete";
  35. cout<<*it;
  36. ms.erase(it);
  37. //}
  38.  
  39.  
  40. for(auto i=ms.begin();i!=ms.end();i++){
  41. cout<<*i<<" ";
  42. }
  43. }
  44. return 0;
  45. }
Success #stdin #stdout 0s 4508KB
stdin
1
6 1
5 2 3 5 7 2
stdout
2 executed
hete22 3 5 5