#P4759. Circular RMQ
Circular RMQ
Circular RMQ
题面翻译
【题目大意】
给定一个环形数列 。
现在有 种操作:
- :将区间 中的每个数增加 。
- :求出区间 中的最小值。
因为数列是环形的,所以当 ,, 时,表示的区间下标为 。
Translated by 小恐。
【输入】
第一行有一个整数 。
第二行为数列的初始状态 , 是整数。
第三行有一个整数 ,表示操作次数。
接下来m行每行为一个操作。如果该行有两个整数 , 表示 操作,如果该行有三个整数 ,, 表示 操作。
【输出】
对于每个 操作输出一行答案。
题目描述
You are given circular array . There are two types of operations with it:
- — this operation increases each element on the segment (inclusively) by ;
- — this operation returns minimal value on the segment (inclusively).
Assume segments to be circular, so if and , it means the index sequence: .
Write program to process given sequence of operations.
输入格式
The first line contains integer ( ). The next line contains initial state of the array: ( ), are integer. The third line contains integer ( ), — the number of operartons. Next lines contain one operation each. If line contains two integer ( ) it means operation, it contains three integers ( ) — operation.
输出格式
For each operation write result for it. Please, do not use %lld specificator to read or write 64-bit integers in C++. It is preffered to use cout (also you may use %I64d).
样例 #1
样例输入 #1
4
1 2 3 4
4
3 0
3 0 -1
0 1
2 1
样例输出 #1
1
0
0