Codeforces Round 1117 (Div. 2)
F1
海狸的跳跃赛道(简单版)
Beaver's Jumping Track (Easy Version)
Codeforces
2500
原题
← EF2 →

海狸的跳跃赛道(简单版)AI (CI翻译)

This is the easy version of the problem. The difference between the versions is that in this version, the constraint on $x$ and time limit are lower. You can hack only if you solved all versions of this problem.

翻译中…

The Beaver is training to jump long distances. The Beaver can already jump $x$ meters. However, just jumping as far as possible is easy and boring. Therefore, the Beaver has created an unusual training track for jumping.

翻译中…

The track consists of $n$ platforms; each platform consists of $d_i$ meter cells. If the Beaver stands on platform number $i$, jumps, and lands back on the same platform, this results in $s_i$ penalty points being awarded; otherwise, no penalty points are given. The Beaver can jump forward any integer number of cells less than or equal to $x$. Note that the Beaver can skip one or more platforms in a single jump without landing on them at all.

翻译中…

The Beaver has unlimited computational power in its mind and always jumps in such a way as to minimize the total penalty for passing the track. Moreover, the track is not constant, and sometimes the lengths and penalties of some platforms change. Learn to calculate what penalty the Beaver will get if it starts standing on the first cell of platform number $l$ and finishes standing on the last cell of platform number $r$.

翻译中…

Input

输入格式

AI (CI翻译)

The first line contains three integers $n$, $q$, $x$ — the number of sections of the track, the number of queries, and the maximum jump length, respectively ($1 \leq n \leq 10^6$; $1 \leq q \leq 10^4$; $1 \leq x \leq 5$).

第一行包含三个整数 $n$、$q$、$x$,分别表示赛道的平台数量、查询数量和最大跳跃距离($1 \leq n \leq 10^6$;$1 \leq q \leq 10^4$;$1 \leq x \leq 5$)。AI (CI翻译)

The second line contains $n$ integers $d_i$ — the lengths of the platforms ($1 \leq d_i \leq 10^7$).

第二行包含 $n$ 个整数 $d_i$,表示各个平台的长度($1 \leq d_i \leq 10^7$)。AI (CI翻译)

The third line contains $n$ integers $s_i$ — the penalties ($1 \leq s_i \leq 10^5$).

第三行包含 $n$ 个整数 $s_i$,表示各个平台的罚分($1 \leq s_i \leq 10^5$)。AI (CI翻译)

The following $q$ lines describe the queries in one of the following formats:

接下来的 $q$ 行描述查询,每次查询的格式为以下三种之一:AI (CI翻译)

  1. "1 $i$ $v$" — set the length of the $i$-th platform to $v$ ($1 \leq i \leq n$; $1 \leq v \leq 10^7$);
  2. "2 $i$ $y$" — set the penalty on the $i$-th platform to $y$ ($1 \leq i \leq n$; $1 \leq y \leq 10^5$);
  3. "? $l$ $r$" — calculate the minimum penalty for passing the track consisting of platforms from $l$ to $r$ ($1 \leq l \leq r \leq n$).
  1. 1 $i$ $v$ —— 将第 $i$ 个平台的长度修改为 $v$($1 \leq i \leq n$;$1 \leq v \leq 10^7$);
  2. 2 $i$ $y$ —— 将第 $i$ 个平台的罚分修改为 $y$($1 \leq i \leq n$;$1 \leq y \leq 10^5$);
  3. ? $l$ $r$ —— 计算通过由第 $l$ 至第 $r$ 个平台组成的赛道所需的最小罚分($1 \leq l \leq r \leq n$)。
AI (CI翻译)

Output

输出格式

AI (CI翻译)

For each query of the third type, output a single number on a separate line — the minimum penalty.

对于每个第三种查询,单独一行输出一个整数,即通过赛道所需的最小罚分。AI (CI翻译)

Note

说明

AI (CI翻译)

During the first query, the lengths of the course sections are $[4, 2, 5]$ with costs $[4, 2, 7]$; the optimal route is

$$1 \rightarrow 4 \rightarrow 6 \rightarrow 8 \rightarrow 11$$ In this case, the penalty is $4 + 0 + 0 + 7 = 11$.

Before the second query, the penalty of the second course increased, but we never get it; thus, the answer to this query is also $11$.

Before the third query, we have the lengths of the courses $[2, 2, 5]$; then the route $$1 \rightarrow 4 \rightarrow 6 \rightarrow 9$$ gives a penalty of 7, as the only penalizing jump is within one platform: $6 \rightarrow 9$.

第一次查询时,各赛道区段的长度为 $[4, 2, 5]$,罚分为 $[4, 2, 7]$;最优路线为

$$1 \rightarrow 4 \rightarrow 6 \rightarrow 8 \rightarrow 11$$

此时罚分为 $4 + 0 + 0 + 7 = 11$。

在第二次查询之前,第二个赛道区段的罚分增加了,但我们不会经过它;因此,这次查询的答案仍然是 $11$。

在第三次查询之前,各赛道区段的长度为 $[2, 2, 5]$;此时路线 $$1 \rightarrow 4 \rightarrow 6 \rightarrow 9$$ 的罚分为 $7$,因为唯一产生罚分的跳跃是在同一个平台内进行的:$6 \rightarrow 9$。AI (CI翻译)

样例

Input #1
5 8 3
4 2 5 1 3
4 2 7 1 5
? 1 3
2 2 10
? 1 3
1 1 2
? 1 3
? 2 5
1 3 2
? 2 5
Output #1
11
11
7
7
0
InputCopy OutputCopy
题目信息
题号
2257F1
时间限制
2 s
内存限制
1024 MB
标签
数据结构
动态规划
矩阵

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。