联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-23:00
  • 微信:codinghelp

您当前位置:首页 >> C/C++编程C/C++编程

日期:2021-12-02 09:42

BBST

Description

You are required to maintain a multiset , which supports the following operations:

1. Insert a number to ;

2. Erase a number equal to from if exists;

3. Find the order of in , i.e., ;

4. Find the -th smallest number in ;

5. Find the precursor of a number in , i.e., if exists;

6. Find the successor of a number in , i.e., if exists.

Input

The first line of the contains an integer , indicating the number of operations followed.

In the next lines, each line contains two integers and , representing an operation, where

stands for the type of the operation.

Output

For each type 3, 4, 5, 6 operation, output a number in one line, representing the answer.

Sample

Sample 1 Input

10

1 106465

4 1

1 317721

1 460929

1 644985

1 84185

1 89851

6 81968

1 492737

5 493598

Sample 1 output

106465

84185

492737

S

x S

x S

x S 1 + ∑v∈S

[v < x]

x S

x S {v}

v∈S,v<x

max

x S {v}

v∈S,v>x

min

n

n opt x opt

Constraints

.

It is guaranteed that the precursor or successor exists for each type or operation.

1 ≤ n ≤ 10

5

, 1 ≤ opt ≤ 6, ?10

7 ≤ x ≤ 10

7

5 6


版权所有:留学生编程辅导网 2020 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。 站长地图

python代写
微信客服:codinghelp