#abc241d. D - Sequence Query
D - Sequence Query
Score : points
问题描述
我们有一个空的序列 。
给定 个查询,按照顺序处理它们。
每个查询属于以下三种类型之一。
-
1 x
:将 插入到 中。 -
2 x k
:在 中小于等于 的元素中,输出第 大的值。 ( 不超过 )
如果 中小于等于 的元素少于 个,则输出-1
。 -
3 x k
:在 中大于等于 的元素中,输出第 小的值。 ( 不超过 )
如果 中大于等于 的元素少于 个,则输出-1
。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
We have an empty sequence .
Given queries, process them in order.
Each query is of one of the following three types.
-
1 x
: Insert to . -
2 x k
: Among the elements of that are less than or equal to , print the -th largest value. ( is no more than )
If there are less than elements of that are less than or equal to , then print-1
. -
3 x k
: Among the elements of that are greater than or equal to , print the -th smallest value. ( is no more than )
If there are less than elements of that are greater than or equal to , then print-1
.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
In the -th query , the type of query (which is either , or ) is given first.
If , then is additionally given; if , then and are additionally given.
In other words, each query is given in one of the following three formats:
Output
Print lines, where is the number of queries such that .
The -th line should contain the answer for the -th such query.
Sample Input 1
11
1 20
1 10
1 30
1 20
3 15 1
3 15 2
3 15 3
3 15 4
2 100 5
1 1
2 100 5
Sample Output 1
20
20
30
-1
-1
1
After have been processed, we have .
For , the elements of greater than or equal to are .
The -st smallest value of them is ; the -nd is ; the -rd is .
update @ 2024/3/10 10:23:31