問題一覧 > 通常問題

No.1234 Typical RMQ

レベル : / AI推定難易度 : 1300 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 191
作問者 : koba-e964 / テスター : 紙ぺーぱー
お気に入りにしたユーザー ProblemId : 1379 / 自分の提出
問題文最終更新日: 2020-08-16 18:22:40
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 266 (順位表) の他の問題:

Problem Statement

For an array, multiple queries of the following two types are given:
(1) adding a value to a range
(2) computing the minimum value of a range
Please answer them.

Input

$N$
$a_1$ $a_2$ $\ldots$ $a_N$
$Q$
$k_1$ $l_1$ $r_1$ $c_1$
$k_2$ $l_2$ $r_2$ $c_2$
$\vdots$
$k_Q$ $l_Q$ $r_Q$ $c_Q$

$1\le N,Q \le 100000$
$-10^{10} \le a_i \le 10^{10}$ for all $i$
$k_i = 1$ or $2$ for all $i$
$1 \le l_i \le r_i \le N$ for all $i$
$-10000 \le c_i \le 10000$ for all $i$
$N$ is the length of the given array, and $a_1, \cdots,a_N$ are the initial values of the array.
If $k_i=1$, the $i$-th query is "update the elements from the $l_i$-th to the $r_i$-th by adding $c_i$ to them".
If $k_i=2$, the $i$-th query is "compute the minimum value among the elements from the $l_i$-th to the $r_i$-th". In this case, $c_i$ is irrelevant.
Note that the initial values and the values of the array after processing queries may not fit in the range of a 32-bit integer.

Output

For each query with $k_i = 2$, print the computed minimum value on one line (print a newline after each number).

Sample

Sample 1
Input
4
1 2 3 4
3
2 1 4 0
1 1 2 3
2 1 4 0
Output
1
3

The initial values are {1,2,3,4}, so the minimum value among the 1st to 4th elements is 1. The 2nd query adds 3 to the 1st through 2nd elements, so the array becomes {4,5,3,4}. Therefore, the output of the 3rd query is 3.

Sample 2
Input
7
-307365022 7783992359 -4511812607 6579404095 5544278142 -2979154502 -351466228
10
1 1 7 -744
2 2 2 0
1 1 7 6176
2 3 3 0
1 1 4 7390
2 6 6 0
2 6 6 0
2 5 5 0
1 3 5 5733
2 5 5 0
Output
7783991615
-4511807175
-2979149070
-2979149070
5544283574
5544289307

Sample 3
Input
16
-5636340242 558311214 179674564 -4196014631 4022013400 5437335202 -2472229134 8341925757 -4153003391 1020988529 4818814275 -1072289912 -3707805533 7612427682 -4413623203 -1139382259
10
1 14 14 -5404
2 12 15 0
1 4 15 1510
2 3 12 0
2 14 14 0
1 7 8 5589
1 10 15 3941
1 5 11 -5813
2 15 15 0
2 3 3 0
Output
-4413623203
-4196013121
7612423788
-4413617752
179674564

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。