Advertisement
a53

mset

a53
Oct 14th, 2017
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. #include <fstream>
  2. #include <set>
  3. using namespace std;
  4. ifstream f("mset.in");
  5. ofstream g("mset.out");
  6. multiset <int> MS;
  7. multiset<int>::iterator itlow,itup,it;
  8. int n,op,x;
  9.  
  10. int main()
  11. {
  12. f>>n;
  13. for(int i=1;i<=n;++i)
  14. {
  15. f>>op;
  16. if(op==1)
  17. {
  18. f>>x;
  19. MS.emplace(x);
  20. }
  21. if(op==2)
  22. {
  23. f>>x;
  24. itlow=MS.lower_bound(x);
  25. itup=MS.upper_bound(x);
  26. MS.erase(itlow,itup); // ^
  27. }
  28. if(op==3)
  29. {
  30. if(MS.empty()) /// Daca multisetul MS e vid
  31. g<<-1<<'\n';
  32. else
  33. {
  34. it=MS.begin();
  35. g<<*it<<' '<<MS.count(*it)<<'\n';
  36. }
  37. }
  38. }
  39. return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement