TopCoder

User's AC Ratio

100.0% (2/2)

Submission's AC Ratio

100.0% (2/2)

Tags

Description

set 是一種能支援插入(已經存在的數字則忽略),刪除某個數字,查詢 set 裡面有幾個元素,查詢最大最小值的資料結構。
這題要你學會使用 set,指令如下。

  • 1 C:將數字 $C$ 插入 set,如果數字 $C$ 已經在裡面則忽略。
  • 2 C:將數字 $C$ 從 set 刪除,如果數字 $C$ 不在裡面則輸出 error
  • 3:查詢目前 set 裡面有多少元素。
  • 4:查詢 set 中的最小值,如果 set 為空則輸出 error
  • 5:查詢 set 中的最大值,如果 set 為空則輸出 error

Input Format

輸入第一行有一個正整數 $N(1 \leq N \leq 100000)$。
之後有 $N$ 行,每行有一個指令,指令如題序所述,其中插入與刪除指令的 $C$ 絕對值不超過 $10^ 9$。

Output Format

請對需要輸出的指令輸出答案並換行。

Sample Input 1

5
1 -1
1 1
3
2 -1
3

Sample Output 1

2
1

Sample Input 2

12
1 5
1 5
1 4
4
5
3
2 3
2 5
4
5
2 4
4

Sample Output 2

4
5
2
error
4
4
error

Hints

Problem Source

Subtasks

No. Testdata Range Constraints Score
1 0~1 範例測資 0
2 0~21 無額外限制 100

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 1000 524288 65536 1 2
1 1000 524288 65536 1 2
2 1000 524288 65536 2
3 1000 524288 65536 2
4 1000 524288 65536 2
5 1000 524288 65536 2
6 1000 524288 65536 2
7 1000 524288 65536 2
8 1000 524288 65536 2
9 1000 524288 65536 2
10 1000 524288 65536 2
11 1000 524288 65536 2
12 1000 524288 65536 2
13 1000 524288 65536 2
14 1000 524288 65536 2
15 1000 524288 65536 2
16 1000 524288 65536 2
17 1000 524288 65536 2
18 1000 524288 65536 2
19 1000 524288 65536 2
20 1000 524288 65536 2
21 1000 524288 65536 2