12567 - Break my heart(mid2)   

Description

I have broken many girls' hearts into pieces. But none of them mad at me. None.

~ by anonymous surgeon

You're a surgeon, you need to mend those girls' hearts. Therefore you need a data structure to support some functions.


This question is about maintain a set that contains only integers.

There will be n instructions.

Each instruction will be either:

insert:

Insert a new element ai into the set. Note that if the element has already in the set, do nothing.

 

print:

print all the element in the set in increasing order.

 

min:

print the number in the set that is the smallest. If there's no number, do nothing.

 

range_erase:

You will have two integer l, r.

You need to erase all the elements ai in the set that l <= ai <= r

 

sum: (Different from practice!!)

print the sum of all the elements in the set.

 

Hint: You can solve this question very fast by using std::set .

These are some functions you may use in your code:

set.begin(), set.size(), set.erase(), set.lower_bound(), set.upper_bound(), set.insert(), note the return value of set.insert(). To traverse through your set, you may also need iterator or type auto(only in c++11!)

 

 

Download the C++ reference.
You will see the file named "12534.cpp" but that's OK.
Just download the file and change the filename extension(副檔名) into "zip" then you can upzip the file and use the reference.
The link is below.

reference.zip

 

 

 

Input

the input will contain several lines.

The first line only contains an integer n

The following are n lines.

Each lines contains a instruction list above.

Note that  0 <= ai, l, r <= 10^9

Range of n: 

testcase 1~4: 1 <= n <= 5000

testcase 5: n = 200000

For testcase 5 there's no "print" instruction!

 

Output

 

For each print instruction, print all the number in the set in increasing order.

Each number is separated by a single blank.(No blank at the the end!)

Remember to print \n at the end of output

 

For each min instruction, print the smallest number in the set.

Remember to print \n at the end of output

Sample Input  Download

Sample Output  Download

Tags




Discuss