Score : $400$ points
We have a horizontal cylinder. Given $Q$ queries, process them in the given order.
Each query is of one of the following two types.
1 x c
: Insert $c$ balls, with a number $x$ written on each of them, to the right end of the cylinder.2 c
: Take out the $c$ leftmost balls contained in the cylinder and print the sum of the numbers written on the balls that have been taken out.We assume that the balls do never change their order in the cylinder.
2 c
is given, there are $c$ or more balls in the cylinder.Input is given from Standard Input in the following format:
$Q$ ${\rm query}_1$ $\vdots$ ${\rm query}_Q$
The $i$-th query ${\rm query}_i$ is in one of the following two formats.
$1$ $x$ $c$
$2$ $c$
Print the response to the queries of type 2 c
in the given order, with newlines in between.
4 1 2 3 2 2 1 3 4 2 3
4 8
2 1 1000000000 1000000000 2 1000000000
1000000000000000000
5 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
There may be nothing you should print.