CF52C.Circular RMQ

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given circular array a0,a1,...,an1a_{0},a_{1},...,a_{n-1} . There are two types of operations with it:

  • inc(lf,rg,v)inc(lf,rg,v) — this operation increases each element on the segment [lf,rg][lf,rg] (inclusively) by vv ;
  • rmq(lf,rg)rmq(lf,rg) — this operation returns minimal value on the segment [lf,rg][lf,rg] (inclusively).

Assume segments to be circular, so if n=5n=5 and lf=3,rg=1lf=3,rg=1 , it means the index sequence: 3,4,0,13,4,0,1 .

Write program to process given sequence of operations.
给你一个圆形数组 a0, a1, ..., an - 1 。可以对它进行两种操作:

inc(lf,rg,v)inc(lf,rg,v) - 此操作会将数据段 [lf, rg] (包括)中的每个元素增加 v ;
rmq(lf,rg)rmq(lf,rg) - 此操作会将数据段 [lf, rg] (包括)中的每个元素返回最小值。- 此操作将返回数据段 [lf, rg] (包含)上的最小值。
假设线段是循环的,因此如果 n = 5 和 lf = 3, rg = 1 ,则表示索引序列: 3, 4, 0, 1 .
编写处理给定操作序列的程序。

输入格式

The first line contains integer nn ( 1<=n<=2000001<=n<=200000 ). The next line contains initial state of the array: a0,a1,...,an1a_{0},a_{1},...,a_{n-1} ( 106<=ai<=106-10^{6}<=a_{i}<=10^{6} ), aia_{i} are integer. The third line contains integer mm ( 0<=m<=2000000<=m<=200000 ), mm — the number of operartons. Next mm lines contain one operation each. If line contains two integer lf,rglf,rg ( 0<=lf,rg<=n10<=lf,rg<=n-1 ) it means rmqrmq operation, it contains three integers lf,rg,vlf,rg,v ( 0<=lf,rg<=n1;106<=v<=1060<=lf,rg<=n-1;-10^{6}<=v<=10^{6} ) — incinc operation.
输入
第一行包含整数 nn ( 1<=n<=2000001<=n<=200000 )。下一行包含数组的初始状态: a0,a1,...,an1a_{0},a_{1},...,a_{n-1} ( 106<=ai<=106-10^{6}<=a_{i}<=10^{6} ),aia_{i} 为整数。第三行包含整数 mm ( 0<=m<=2000000<=m<=200000 ), mm - 操作数。接下来的 m 行各含一个操作数。如果该行包含两个整数lf,rglf,rg ( 0<=lf,rg<=n10<=lf,rg<=n-1 ) 表示 rmq 次运算,包含三个整数 lf,rg,vlf,rg,v ( 0<=lf,rg<=n1;106<=v<=1060<=lf,rg<=n-1;-10^{6}<=v<=10^{6} ) — incinc 次运算。

输出格式

For each rmqrmq 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)。

输入输出样例

  • 输入#1

    4
    1 2 3 4
    4
    3 0
    3 0 -1
    0 1
    2 1
    

    输出#1

    1
    0
    0
    
首页