Advertisement
newb_ie

Untitled

Aug 24th, 2021
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #include <ext/pb_ds/assoc_container.hpp>
  5. #include <ext/pb_ds/tree_policy.hpp>
  6. using namespace __gnu_pbds;
  7. typedef tree<int64_t, null_type, less_equal<int64_t>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
  8.  
  9. int main () {
  10. ios::sync_with_stdio(false);
  11. cin.tie(nullptr);
  12. cout.tie(nullptr);
  13. vector<int64_t> a = {1,2,3,4,5};
  14. ordered_set s;
  15. for (int i = 0; i < 5; ++i) s.insert(a[i]);
  16. //~ s.find_by_order(); print element in index k
  17. //~ s.order_of_key(); find how many elements are there <= k
  18. //~ cout << s.order_of_key(4) << '\n';
  19. //~ cout << *s.find_by_order(3 - 1) << '\n';
  20. //~ a = {.......}
  21. //~ q
  22. //~ l , r
  23. //~ cout << s.order_of_key(r + 1) - s.order_of_key(l);
  24. for (int i = 1; i <= 3; ++i) {
  25. int type,qi;
  26. cin >> type >> qi;
  27. if (type == 1) {
  28. s.insert(qi);
  29. } else if (type == 2) {
  30. cout << s.order_of_key(qi + 1) << '\n';
  31. } else {
  32. cout << s.order_of_key(qi + 1) << '\n';
  33. }
  34. }
  35. }
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement