
I x,插入一个数 x;
PM,输出当前集合中的最小值;
DM,删除当前集合中的最小值(数据保证此时的最小值唯一);
D k,删除第 k 个插入的数;
C k x,修改第 k 个插入的数,将其变为 x ;
#include#include using namespace std; const int N=1e5+5; int n,sz,ct; int h[N],cnt[N],tm[N]; void heap_swap(int a,int b) { swap(h[a],h[b]); swap(cnt[tm[a]],cnt[tm[b]]); swap(tm[a],tm[b]); } void down(int k) { int t=k; if(2*t<=sz && h[k]>h[2*t]) k=2*t; if(2*t+1<=sz && h[k]>h[2*t+1]) k=2*t+1; if(t!=k) { heap_swap(t,k); down(k); } } void up(int k) { int t=k; if(t/2>=1 && h[k] >n; while(n--) { string ch; int k,x; cin>>ch; if(ch=="I") { cin>>x; insert(x); } if(ch=="PM") cout< >k; k=cnt[k]; heap_swap(k,sz); sz--; down(k); up(k); } if(ch=="C") { cin>>k>>x; k=cnt[k]; h[k]=x; down(k); up(k); } } return 0; }