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; }
本文在博客园发布,作者:limited_Infinite,转载请注明原文链接:https://www.cnblogs.com/limitedInfinite/p/14791911.html