7分平板电视求调
查看原帖
7分平板电视求调
186546
lwyznoip楼主2024/8/8 14:49
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
using namespace std;
using namespace __gnu_pbds;
tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> t;
int n;
int k, res;
signed main() {
    cin >> n;
    for (int i = 1; i <= n; i ++) {
        int op;
		cin >> op >> k;
        switch (op) {
            case 1: t.insert (k); break;
            case 2: t.erase (t.lower_bound (k)); break;
            case 3: cout << t.order_of_key (k) << endl; break;
            case 4: cout << (*t.find_by_order (k - 1)) << endl; break;
            case 5: cout << (*--t.lower_bound (k)) << endl; break;
            case 6: cout << (*t.upper_bound (k)) << endl; break;
        }
    }
}
2024/8/8 14:49
加载中...