inlineintread(){ int s = 0, x = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == '-') x = -x; ch = getchar(); } while (isdigit(ch)) { s = s * 10 + ch - '0'; ch = getchar(); } return s * x; }
constint MAXN = 1e6 + 10;
int n, q;
structBIT { int ss[(1 << 21) + 10];
#define lb(x) ((x) & (-(x))) voidinsert(int s, int x){ while (s <= n) ss[s] += x, s += lb(s); } intquery(int rank){ int root = 0; for (int i = 20; i >= 0; --i) { int delta = (1 << i); // printf("root = %d, delta = %d\n", root, delta); if (root + delta <= n && ss[root + delta] <= rank) { root += delta; rank -= ss[root]; } } return root + 1; } intquerysum(int x){ int ret = 0; while (x >= 1) { ret += ss[x]; x -= lb(x); } return ret; } intquery_v2(int rank){ int l = 1, r = n, ans = n; while (l <= r) { // printf("now: l = %d, r = %d\n", l, r); int mid = (l + r) >> 1; if (querysum(mid) >= rank) r = mid - 1, ans = mid; else l = mid + 1; } return ans; } } bit;
intmain(){ n = read(); q = read(); int siz = n; for (int i = 1; i <= n; ++i) bit.insert(read(), 1); for (int i = 1; i <= q; ++i) { int x = read(); if (x > 0) { bit.insert(x, 1); ++siz; } else { bit.insert(bit.query_v2(-x), -1); --siz; } // printf("content: "); // for (int i = 1; i <= n; ++i) // printf("%d%c", bit.ss[i], " \n"[i == n]); } if (siz == 0) puts("0"); elseprintf("%d\n", bit.query_v2(1)); return0; }