#abc253c. C - Max - Min Query
C - Max - Min Query
Score : points
问题描述
我们有一个初始为空的整数多重集 。
给定 个查询,按照顺序处理它们。每个查询属于以下类型之一。
-
1 x
:将一个整数 插入到集合 中。 -
2 x c
:从集合 中删除整数 ,删除次数为 集合 中包含的 的数量))。 -
3
:打印集合 中的最大值减去最小值的结果。在此查询给出时,保证集合 不为空。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
We have a multiset of integers , which is initially empty.
Given queries, process them in order. Each query is of one of the following types.
-
1 x
: Insert an into . -
2 x c
: Remove an from times, where the number of 's contained in . -
3
: Print maximum value of minimum value of . It is guaranteed that is not empty when this query is given.
Constraints
- When a query of type
3
is given, is not empty. - All values in input are integers.
Input
Input is given from Standard Input in the following format:
, which denotes the -th query, is in one of the following formats:
Output
Print the answers for the queries of type 3
in the given order, separated by newlines.
Sample Input 1
8
1 3
1 2
3
1 2
1 7
3
2 2 3
3
Sample Output 1
1
5
4
The multiset transitions as follows.
- -st query: insert into . is now .
- -nd query: insert into . is now .
- -rd query: the maximum value of is and its minimum value is , so print .
- -th query: insert into . is now .
- -th query: insert into . is now .
- -th query: the maximum value of is and its minimum value is , so print .
- -th query: since there are two 's in and , remove from twice. is now .
- -th query: the maximum value of is and its minimum value is , so print .
Sample Input 2
4
1 10000
1 1000
2 100 3
1 10
Sample Output 2
If the given queries do not contain that of type , nothing should be printed.
update @ 2024/3/10 10:47:31