Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- #include <ext/pb_ds/assoc_container.hpp>
- #include <ext/pb_ds/tree_policy.hpp>
- using namespace __gnu_pbds;
- typedef tree<int64_t, null_type, less_equal<int64_t>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
- int main () {
- ios::sync_with_stdio(false);
- cin.tie(nullptr);
- cout.tie(nullptr);
- vector<int64_t> a = {1,2,3,4,5};
- ordered_set s;
- for (int i = 0; i < 5; ++i) s.insert(a[i]);
- //~ s.find_by_order(); print element in index k
- //~ s.order_of_key(); find how many elements are there <= k
- //~ cout << s.order_of_key(4) << '\n';
- //~ cout << *s.find_by_order(3 - 1) << '\n';
- //~ a = {.......}
- //~ q
- //~ l , r
- //~ cout << s.order_of_key(r + 1) - s.order_of_key(l);
- for (int i = 1; i <= 3; ++i) {
- int type,qi;
- cin >> type >> qi;
- if (type == 1) {
- s.insert(qi);
- } else if (type == 2) {
- cout << s.order_of_key(qi + 1) << '\n';
- } else {
- cout << s.order_of_key(qi + 1) << '\n';
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement