赛前想看一下STL, butWA了
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <bits/extc++.h>
//== == == =read= == == ==
namespace SuperI {
const int Mbuf = 2 << 21;
static std::streambuf *inbuf = std::cin.rdbuf();
char buf[Mbuf], *head = buf, *tail = buf, ___c;
inline char getchar() {
return ((head == tail) && (tail = (head = buf) + inbuf->sgetn(buf, Mbuf), head == tail)) ? EOF : *head++;
}
inline void read(int *const p) {
*p = 0;
for (; ___c < '0' || ___c > '9'; ___c = getchar());
for (; ___c >= '0' && ___c <= '9'; *p = *p * 10 + (___c ^ 48), ___c = getchar());
}
inline void read(long long *const p) {
*p = 0;
for (; ___c < '0' || ___c > '9'; ___c = getchar());
for (; ___c >= '0' && ___c <= '9'; *p = *p * 10 + (___c ^ 48), ___c = getchar());
}
}
__gnu_pbds::tree<long long, __gnu_pbds::null_type, std::less<long long>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update> T;
int n;
//== == == =main= == == ==
int main() {
using SuperI::read;
#ifndef ONLINE_JUDGE
freopen("P3369.in", "r", stdin);
freopen("P3369.out", "w", stdout);
#endif
read(&n);
for (int i = 1; i <= n; ++i) {
static int op;
static long long x;
read(&op);
read(&x);
if (op == 1) T.insert((x << 18) + i);
else if (op == 2) T.erase(T.lower_bound(x << 18));
else if (op == 3) {long long ans = T.order_of_key(x << 18); std::cout << ans + 1 << '\n';}
else if (op == 4) {long long ans = *T.find_by_order(x - 1); std::cout << (ans >> 18) << '\n';}
else if (op == 5) {long long ans = *--T.lower_bound(x << 18); std::cout << (ans >> 18) << '\n';}
else {long long ans = *T.upper_bound((x << 18) + n); std::cout << (ans >> 18) << '\n';}
}
return 0;
}