fork(12) download
  1. #include <iostream>
  2. #include<ext/pb_ds/assoc_container.hpp>
  3. #include<ext/pb_ds/tree_policy.hpp>
  4. using namespace std;
  5.  
  6. using namespace __gnu_pbds;
  7. typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
  8. tree_order_statistics_node_update> ordered_multiset;
  9.  
  10. int main() {
  11. ordered_multiset ms;
  12. vector<int> v{1, 1, 2, 2, 3, 4, 5, 6, 6};
  13.  
  14. for(int i : v) ms.insert(i);
  15.  
  16. cout << "Ordered Multiset: ";
  17. for(auto x : ms) cout << x << ' '; cout << '\n';
  18.  
  19. cout << "Lower bound of 2: " << *ms.lower_bound(2) << '\n';
  20. cout << "Upper bound of 2: " << *ms.upper_bound(2) << '\n';
  21. return 0;
  22. }
Success #stdin #stdout 0s 4392KB
stdin
Standard input is empty
stdout
Ordered Multiset: 1 1 2 2 3 4 5 6 6 
Lower bound of 2: 3
Upper bound of 2: 2