15641561

#include <iostream>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
struct node{
    int val,id;
    node(int a,int b){
        val=a;
        id=b;
    }
    inline bool operator > (const node b)const {
        return val==b.val?id>b.id:val>b.val;
    }
};
tree<int,null_type,greater<int>,rb_tree_tag,tree_order_statistics_node_update> t,temp;
int n,min_cash,tcin,s,ans,com;

int main() {
    ios::sync_with_stdio(false);
    cin>>n;
    for (int i = 0; i < n; ++i) {
        cin>>com>>tcin;
        if(com==1) t.insert((tcin<<20)+i);
        else if(com==2){
            t.erase(t.lower_bound(tcin<<20));
        }else if(com==3){
            cout<<t.order_of_key((tcin<<20)+1)<<endl;
        }else if(com==4){
            ans=*t.find_by_order(tcin-1);
        }else if(com==5){
            ans=*--t.lower_bound(tcin<<20);
        }else ans=*t.lower_bound((tcin+1)<<20);
        printf("%lld\n",ans>>20);//一并处理ans
    }
    return 0;
}

 

posted @ 2021-05-20 22:36  limited_Infinite  阅读(54)  评论(0编辑  收藏  举报
// //返回顶部 //返回顶部按钮