8 1 3 1 2 3 1 2 1 7 3 2 2 3 3
1
5
4
The multiset $S$ transitions as follows.
* $1$\-st query: insert $3$ into $S$. $S$ is now $\lbrace 3 \rbrace$.
* $2$\-nd query: insert $2$ into $S$. $S$ is now $\lbrace 2, 3 \rbrace$.
* $3$\-rd query: the maximum value of $S = \lbrace 2, 3\rbrace$ is $3$ and its minimum value is $2$, so print $3-2=1$.
* $4$\-th query: insert $2$ into $S$. $S$ is now $\lbrace 2,2,3 \rbrace$.
* $5$\-th query: insert $7$ into $S$. $S$ is now $\lbrace 2, 2,3, 7\rbrace$.
* $6$\-th query: the maximum value of $S = \lbrace 2,2,3, 7\rbrace$ is $7$ and its minimum value is $2$, so print $7-2=5$.
* $7$\-th query: since there are two $2$'s in $S$ and $\mathrm{min(2,3)} = 2$, remove $2$ from $S$ twice. $S$ is now $\lbrace 3, 7\rbrace$.
* $8$\-th query: the maximum value of $S = \lbrace 3, 7\rbrace$ is $7$ and its minimum value is $3$, so print $7-3=4$.4 1 10000 1 1000 2 100 3 1 10
If the given queries do not contain that of type $3$, nothing should be printed.
{
"problem": {
"name": "Max - Min Query",
"description": {
"content": "We have a multiset of integers $S$, which is initially empty. Given $Q$ queries, process them in order. Each query is of one of the following types. * `1 x`: Insert an $x$ into $S$. * `2 x c",
"description_type": "Markdown"
},
"platform": "AtCoder",
"limit": {
"time_limit": 2000,
"memory_limit": 262144
},
"difficulty": "None",
"is_remote": true,
"is_sync": true,
"sync_url": null,
"sign": "abc253_c"
},
"statements": [
{
"statement_type": "Markdown",
"content": "We have a multiset of integers $S$, which is initially empty.\nGiven $Q$ queries, process them in order. Each query is of one of the following types.\n\n* `1 x`: Insert an $x$ into $S$.\n \n* `2 x c...",
"is_translate": false,
"language": "English"
}
]
}