int main() { freopen("Text/ORDERSET.txt","r",stdin); int Q; scanf("%d",&Q); Treap oTreap; while(Q--) { char t[5]; int p; scanf("%s%d",t,&p); if(t[0]=='I') { oTreap.Insert(p); } else if(t[0]=='D') { oTreap.Delete(p); } else if(t[0]=='K') { int v = oTreap.FindKth(p); if(v > -INF) { printf("%d\n",v); } else puts("invalid"); } else { int v = oTreap.Count(p); printf("%d\n",v); } } return 0; }
void solve(){ int N,X; char ch[5]; scanf("%d",&N); Treap root; while(N--){ scanf("%s%d",ch,&X); if (ch[0] == 'I') root.Insert_unq(X);//, root.print(); else if (ch[0] == 'D') root.Erase(X); else if (ch[0] == 'C'){ int res = root.Count(X); printf("%d\n",res); } else { int res = root.Kth(X); if (res == INT_MIN) printf("invalid\n"); else printf("%d\n",res); } } }