#abc247d. D - Cylinder
D - Cylinder
Score : points
问题描述
我们有一个水平放置的圆柱体。给定 个查询,按照给定顺序处理它们。
1 x c
:在圆柱体右侧末端插入带有数字 的球共 个。2 c
:从圆柱体内取出最左边的 个球,并输出被取出球上数字之和。
我们假设球在圆柱体内的顺序始终保持不变。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
We have a horizontal cylinder. Given queries, process them in the given order.
Each query is of one of the following two types.
1 x c
: Insert balls, with a number written on each of them, to the right end of the cylinder.2 c
: Take out the 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.
Constraints
- Whenever a query of type
2 c
is given, there are or more balls in the cylinder. - All values in input are integers.
Input
Input is given from Standard Input in the following format:
The -th query is in one of the following two formats.
Output
Print the response to the queries of type 2 c
in the given order, with newlines in between.
Sample Input 1
4
1 2 3
2 2
1 3 4
2 3
Sample Output 1
4
8
- For the -st query, insert balls, with a number written on each of them, to the right end of the cylinder.
The cylinder has now balls with numbers written on them, from left to right. - For the -nd query, take out the leftmost balls contained in the cylinder.
The numbers written on the balls taken out are , for a sum of , which should be printed. The cylinder has now a ball with a number written on it, from left to right. - For the -rd query, insert balls, with a number written on each of them, to the right end of the cylinder.
The cylinder has now balls with numbers written on them, from left to right. - For the -th query, take out the leftmost balls contained in the cylinder.
The numbers written on the balls taken out are , for a sum of , which should be printed. The cylinder has now balls with numbers written on them, from left to right.
Sample Input 2
2
1 1000000000 1000000000
2 1000000000
Sample Output 2
1000000000000000000
Sample Input 3
5
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
Sample Output 3
There may be nothing you should print.
update @ 2024/3/10 10:35:45