knightnemo commited on
Commit
b412d76
·
verified ·
1 Parent(s): 9f3f15b

Upload code_segments/segment_215.txt with huggingface_hub

Browse files
Files changed (1) hide show
  1. code_segments/segment_215.txt +28 -0
code_segments/segment_215.txt ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Ksyusha decided to start a game development company. To stand out among competitors and achieve success, she decided to write her own game engine. The engine must support a set initially consisting of $n$ distinct integers $a_1, a_2, \ldots, a_n$.
2
+
3
+ The set will undergo $m$ operations sequentially. The operations can be of the following types:
4
+
5
+ * Insert element $x$ into the set; * Remove element $x$ from the set; * Report the $k$-load of the set.
6
+
7
+ The $k$-load of the set is defined as the minimum positive integer $d$ such that the integers $d, d + 1, \ldots, d + (k - 1)$ do not appear in this set. For example, the $3$-load of the set $\\{3, 4, 6, 11\\}$ is $7$, since the integers $7, 8, 9$ are absent from the set, and no smaller value fits.
8
+
9
+ Ksyusha is busy with management tasks, so you will have to write the engine. Implement efficient support for the described operations.
10
+
11
+ The first line contains an integer $t$ ($1 \le t \le 10^4$) — the number of test cases.
12
+
13
+ The following lines describe the test cases.
14
+
15
+ The first line contains an integer $n$ ($1 \le n \le 2 \cdot 10^5$) — the initial size of the set.
16
+
17
+ The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_1 < a_2 < \ldots < a_n \le 2 \cdot 10^6$) — the initial state of the set.
18
+
19
+ The third line contains an integer $m$ ($1 \le m \le 2 \cdot 10^5$) — the number of operations.
20
+
21
+ The next $m$ lines contain the operations. The operations are given in the following format:
22
+
23
+ * + $x$ ($1 \le x \le 2 \cdot 10^6$) — insert element $x$ into the set (it is guaranteed that $x$ is not in the set); * - $x$ ($1 \le x \le 2 \cdot 10^6$) — remove element $x$ from the set (it is guaranteed that $x$ is in the set); * ? $k$ ($1 \le k \le 2 \cdot 10^6$) — output the value of the $k$-load of the set.
24
+
25
+ It is guaranteed that the sum of $n$ across all test cases does not exceed $2 \cdot 10^5$, and the same holds for $m$.
26
+
27
+ For each test case, output the answers to the operations of type "?".
28
+