fork(1) 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. template<typename T> using ordered_multiset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
  8.  
  9. int main() {
  10. ordered_multiset<int>ms;
  11. vector<int> v{1, 1, 2, 2, 3, 5, 6, 6};
  12.  
  13. for(int i : v) ms.insert(i);
  14.  
  15. cout << "Ordered Multiset: ";
  16. for(auto x : ms) cout << x << ' '; cout << '\n';
  17.  
  18. cout << "Lower bound of 2: " << *ms.lower_bound(4) << '\n';
  19. cout << "Upper bound of 2: " << *ms.upper_bound(4) << '\n';
  20. return 0;
  21. }
Success #stdin #stdout 0.01s 5324KB
stdin
Standard input is empty
stdout
Ordered Multiset: 1 2 3 5 6 
Lower bound of 2: 5
Upper bound of 2: 5