static void Solve(IO io) { var kMax = 200000; var bit = new BinaryIndexedTree <int>(kMax + 1, Group <int> .GetSumGroup()); var q = io.I; for (var i = 0; i < q; i++) { var t = io.C; var x = io.I; if (t == '2') { var ok = kMax; var ng = -1; while (Abs(ok - ng) > 1) { var mid = (ok + ng) / 2; if (bit.Concat(mid) >= x) { ok = mid; } else { ng = mid; } } io.Write(ok); bit[ok] = 0; } else { bit[x] = 1; } } }