#include #include #include #include using namespace std; int n; vector a; int main() { //加快读入 ios::sync_with_stdio(false), cin.tie(0); cin >> n; int op, x; while (n--) { cin >> op >> x; if (op == 1) a.insert(lower_bound(a.begin(), a.end(), x), x); //插入数值x else if (op == 2) a.erase(lower_bound(a.begin(), a.end(), x)); //删除数值x else if (op == 3) printf("%d\n", lower_bound(a.begin(), a.end(), x) - a.begin() + 1); //查询数值 x 的排名 else if (op == 4) printf("%d\n", a[x - 1]); //查询排名为 x 的数值 else if (op == 5) printf("%d\n", *--lower_bound(a.begin(), a.end(), x)); //求数值 x 的前驱 else if (op == 6) printf("%d\n", *upper_bound(a.begin(), a.end(), x)); //求数值 x 的后继 } return 0; }