

Time Limit: 2 sec / Memory Limit: 1024 MB
配点 : 点
問題文
空の列 があります。クエリが 個与えられるので、与えられた順番に処理してください。
クエリは次の 種類のいずれかです。
1 x
: の最後尾に を追加する。2
: の最初の要素を出力する。その後、その要素を削除する。このクエリが与えられるとき、 は空でないことが保証される。3
: を昇順にソートする。
制約
- クエリ
2
が与えられるとき、 は空でない。 - 入力は全て整数である。
入力
入力は以下の形式で標準入力から与えられる。
番目のクエリ では、まずクエリの種類 ( のいずれか)が与えられる。 の場合はさらに整数 が追加で与えられる。
すなわち、各クエリは以下に示す つの形式のいずれかである。
出力
を満たすクエリの回数を として 行出力せよ。
行目では 番目のそのようなクエリに対する答えを出力せよ。
入力例 1Copy
8 1 4 1 3 1 2 1 1 3 2 1 0 2
出力例 1Copy
1 2
入力例 において、 番目のクエリを処理した後の の状態を 行目に示すと以下のようになります。
入力例 2Copy
9 1 5 1 5 1 3 2 3 2 1 6 3 2
出力例 2Copy
5 3 5
入力例 において、 番目のクエリを処理した後の の状態を 行目に示すと以下のようになります。
Score : points
Problem Statement
We have an empty sequence . You will be given queries, which should be processed in the order they are given. Each query is of one of the three kinds below:
1 x
: Append to the end of .2
: Print the element at the beginning of . Then, delete that element. It is guaranteed that will not empty when this query is given.3
: Sort in ascending order.
Constraints
- will not be empty when a query
2
is given. - All values in input are integers.
Input
Input is given from Standard Input in the following format:
The -th query, , begins with the kind of query (, , or ). If , the line additionally has an integer .
In other words, each query is in one of the three formats below.
Output
Print lines, where is the number of queries with .
The -th line should contain the response for the -th such query.
Sample Input 1Copy
8 1 4 1 3 1 2 1 1 3 2 1 0 2
Sample Output 1Copy
1 2
The -th line below shows the contents of after the -th query is processed in Sample Input .
Sample Input 2Copy
9 1 5 1 5 1 3 2 3 2 1 6 3 2
Sample Output 2Copy
5 3 5
The -th line below shows the contents of after the -th query is processed in Sample Input .