#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const int maxn = 300300;
int c[maxn];
int lowbit(int x) {
return x&(-x);
}
int sum(int x) {
int s = 0;
for(int i=x;i>0;i-=lowbit(i))
s += c[i];
return s;
}
int main() {
int m;
while(~scanf("%d",&m)) {
memset(c,0,sizeof(c));
while(m--) {
int op;
scanf("%d",&op);
if(op == 0) {
int x;
scanf("%d",&x);
for(int i=x;i<maxn;i+=lowbit(i)) c[i] ++;
}
else if(op==1) {
int x;
scanf("%d",&x);
int s = sum(x) - sum(x-1);
if(s) for(int i=x;i<maxn;i+=lowbit(i)) c[i] --;
else printf("No Elment!\n");
}
else {
int x , k;
scanf("%d%d",&x,&k);
k += sum(x);
int l = 1 , r = maxn - 1;
while(l < r) {
int mid = (l + r) >> 1;
if(sum(mid) < k) l = mid + 1;
else r = mid;
}
if(sum(l) < k) printf("Not Find!\n");
else printf("%d\n",l);
}
}
}
return 0;
}
posted on 2012-10-11 10:11
YouAreInMyHeart 阅读(102)
评论(0) 编辑 收藏 引用