rt,58pts,WA #8 #13,RE #9 - 12
#8 本地调试正确,使用 vector+二分 STL
#include <bits/stdc++.h>
using namespace std;
#define DEBUG 1
#define int long long
#define unint unsigned long long
#define double long double
#define fastdouble register double
#define fastint register long long
#define fastchar register char
#define faststring register string
#define fastbool register bool
#define fastunint register unint
#define fast__int128 register __int128
#define fastT register T
#define cdouble(a) fixed << setprecision(a)
#define isendl(a) (a == '\n' || a == '\r' || a == '\t') ? 1 : 0
#define isword(a) ((a >= 'a' && a <= 'z') || (a >= 'A' && a <= 'Z')) ? 1 : 0
#define isword_abc (a >= 'a' && a <= 'z') ? 1 : 0
#define isword_ABC (a >= 'A' && a <= 'Z') ? 1 : 0
// 快读可略过
struct IO{
#define MAXSIZE (1 << 20)
#define isdigit(x) (x >= '0' && x <= '9')
char buf[MAXSIZE], *p1, *p2;
char pbuf[MAXSIZE], *pp;
#if DEBUG
#else
IO() : p1(buf), p2(buf), pp(pbuf){}
~IO() {fwrite(pbuf, 1, pp - pbuf, stdout);}
#endif
inline char gc(){
#if DEBUG
return getchar();
#endif
if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, MAXSIZE, stdin);
return p1 == p2 ? ' ' : *p1++;
}
inline bool Blank(fastchar ch){return ch == ' ' || isendl(ch);}
inline int read(){
fastdouble tmp = 1;
fastint x = 0;
fastchar ch = gc(), sign;
for (; !isdigit(ch); ch = gc())sign = ch;
for (; isdigit(ch); ch = gc())x = (x << 3) + (x << 1) + (ch ^ 48);
if (ch == '.')
for (ch = gc(); isdigit(ch); ch = gc())
tmp /= 10.0, x += tmp * (ch ^ 48);
return (sign == '-' ? x = (x ^ -1) + 1 : x);
}
inline void read(fastchar *s) {
char ch = gc();
for (; Blank(ch); ch = gc());
for (; !Blank(ch); ch = gc()) *s++ = ch;
*s = 0;
}
inline void read(fastchar &c){for (c = gc(); Blank(c); c = gc());}
inline __int128 read__int128(){
fastchar ch, c;__int128 res;
while (ch = gc(), !isdigit(ch))c = ch;
res = (ch ^ 48);
while (ch = gc(), isdigit(ch))res = (res << 3) + (res << 1) + (ch ^ 48);
if (c == '-')res = (res ^ -1) + 1;
return res;
}
inline void push(const fastchar &c) {
#if DEBUG
putchar(c);
#else
if (pp - pbuf == MAXSIZE) fwrite(pbuf, 1, MAXSIZE, stdout), pp = pbuf;
*pp++ = c;
#endif
}
template <class T>
inline void write(fastT x){
if (x < 0) x = x ^ (-1) + 1, push('-');
fastT sta[35], top = 0;
do {sta[top++] = x % 10, x /= 10;
} while (x);
while (top)push(sta[--top] + '0');
}
template <class T>
inline void write(fastT x, fastchar lastChar){write(x), push(lastChar);}
inline void write(faststring str){
const fastint len = str.size();
for (int i = 0; i < len; ++i)push(str[i]);
}
inline void write(faststring str, fastchar lastchar){write(str), push(lastchar);}
inline void write(fastchar *s){while (*s)push(*s++);}
inline void write(fastchar *s, fastchar lastchar){write(s), push(lastchar);}
template <class T>
inline void write(fast__int128 x){
if (x < 0) x = -x, push('-');
fast__int128 sta[135], top = 0;
do {sta[top++] = x % 10, x /= 10;
} while (x);
while (top) push(sta[--top] + '0');
}
template <class T>
inline void write(fast__int128 x, fastchar lastchar){write(x), push(lastchar);}
}io;
#define endl io.push('\n')
#define blank io.push(' ')
#define de1 io.push('!')
#define de2 io.push('?')
#define FALSE io.write(-1)
const int N = 1e5 + 5, M = 1e5 + 5;
bool Is_multiple_sets = 0;
int T = 1, n, len;
vector <int> vt;
#undef int
#undef unint
#undef double
#undef fastint
#undef fastdouble
#undef fastchar
#undef faststring
#undef fastbool
#undef fastunint
#undef fast__int128
#undef fastT
#define int register long long
signed main(){
//ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
//T = io.read();
for (int Multiple_sets = 1; Multiple_sets <= T || Is_multiple_sets; ++Multiple_sets){
n = io.read();
while (n--){
int op = io.read(), x = io.read();
if (op == 1){
if (!len){
vt.push_back(x);
++len;
continue;
}
int p = lower_bound(vt.begin(), vt.end(), x) - vt.begin();
vt.insert(vt.begin() + p, x);
++len;
} else if (op == 2){
int p = lower_bound(vt.begin(), vt.end(), x) - vt.begin();
vt.erase(vt.begin() + p);
--len;
} else if (op == 3){
int p = lower_bound(vt.begin(), vt.end(), x) - vt.begin();
io.write(p + 1, '\n');
} else if (op == 4){
if (x > len){
io.write(vt[len - 1], '\n');
continue;
}
io.write(vt[x - 1], '\n');
} else if (op == 5){
int p = lower_bound(vt.begin(), vt.end(), x) - vt.begin();
io.write(vt[p - 1], '\n');
} else if (op == 6){
int p = upper_bound(vt.begin(), vt.end(), x) - vt.begin();
io.write(vt[p], '\n');
}
}
}
return 0;
}