A8032 | Circular RMQ
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
You are given circular array $a_{0},a_{1},...,a_{n-1}$ . There are two types of operations with it:
- $inc(lf,rg,v)$ — this operation increases each element on the segment $[lf,rg]$ (inclusively) by $v$ ;
- $rmq(lf,rg)$ — this operation returns minimal value on the segment $[lf,rg]$ (inclusively).
Assume segments to be circular, so if $n=5$ and $lf=3,rg=1$ , it means the index sequence: $3,4,0,1$ .
Write program to process given sequence of operations.
给你一个圆形数组 a0, a1, ..., an - 1 。可以对它进行两种操作:
$inc(lf,rg,v)$ - 此操作会将数据段 [lf, rg] (包括)中的每个元素增加 v ;
$rmq(lf,rg)$ - 此操作会将数据段 [lf, rg] (包括)中的每个元素返回最小值。- 此操作将返回数据段 [lf, rg] (包含)上的最小值。
假设线段是循环的,因此如果 n = 5 和 lf = 3, rg = 1 ,则表示索引序列: 3, 4, 0, 1 .
编写处理给定操作序列的程序。
- $inc(lf,rg,v)$ — this operation increases each element on the segment $[lf,rg]$ (inclusively) by $v$ ;
- $rmq(lf,rg)$ — this operation returns minimal value on the segment $[lf,rg]$ (inclusively).
Assume segments to be circular, so if $n=5$ and $lf=3,rg=1$ , it means the index sequence: $3,4,0,1$ .
Write program to process given sequence of operations.
给你一个圆形数组 a0, a1, ..., an - 1 。可以对它进行两种操作:
$inc(lf,rg,v)$ - 此操作会将数据段 [lf, rg] (包括)中的每个元素增加 v ;
$rmq(lf,rg)$ - 此操作会将数据段 [lf, rg] (包括)中的每个元素返回最小值。- 此操作将返回数据段 [lf, rg] (包含)上的最小值。
假设线段是循环的,因此如果 n = 5 和 lf = 3, rg = 1 ,则表示索引序列: 3, 4, 0, 1 .
编写处理给定操作序列的程序。
输入格式
The first line contains integer $n$ ( $1<=n<=200000$ ). The next line contains initial state of the array: $a_{0},a_{1},...,a_{n-1}$ ( $-10^{6}<=a_{i}<=10^{6}$ ), $a_{i}$ are integer. The third line contains integer $m$ ( $0<=m<=200000$ ), $m$ — the number of operartons. Next $m$ lines contain one operation each. If line contains two integer $lf,rg$ ( $0<=lf,rg<=n-1$ ) it means $rmq$ operation, it contains three integers $lf,rg,v$ ( $0<=lf,rg<=n-1;-10^{6}<=v<=10^{6}$ ) — $inc$ operation.
输入
第一行包含整数 $n$ ( $1<=n<=200000$ )。下一行包含数组的初始状态: $a_{0},a_{1},...,a_{n-1}$ ( $-10^{6}<=a_{i}<=10^{6}$ ),$a_{i}$ 为整数。第三行包含整数 $m$ ( $0<=m<=200000$ ), $m$ - 操作数。接下来的 m 行各含一个操作数。如果该行包含两个整数$lf,rg$ ( $0<=lf,rg<=n-1$ ) 表示 rmq 次运算,包含三个整数 $lf,rg,v$ ( $0<=lf,rg<=n-1;-10^{6}<=v<=10^{6}$ ) — $inc$ 次运算。
输入
第一行包含整数 $n$ ( $1<=n<=200000$ )。下一行包含数组的初始状态: $a_{0},a_{1},...,a_{n-1}$ ( $-10^{6}<=a_{i}<=10^{6}$ ),$a_{i}$ 为整数。第三行包含整数 $m$ ( $0<=m<=200000$ ), $m$ - 操作数。接下来的 m 行各含一个操作数。如果该行包含两个整数$lf,rg$ ( $0<=lf,rg<=n-1$ ) 表示 rmq 次运算,包含三个整数 $lf,rg,v$ ( $0<=lf,rg<=n-1;-10^{6}<=v<=10^{6}$ ) — $inc$ 次运算。
输出格式
For each $rmq$ 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).
输出
为每个 rmq 操作写入结果。请不要在 C++ 中使用 %lld 特指符来读写 64 位整数。最好使用 cout(也可以使用 %I64d)。
输出
为每个 rmq 操作写入结果。请不要在 C++ 中使用 %lld 特指符来读写 64 位整数。最好使用 cout(也可以使用 %I64d)。
输入输出样例
输入 #1
4 1 2 3 4 4 3 0 3 0 -1 0 1 2 1
输出 #1
1 0 0
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted