海狸的跳跃赛道(困难版本)AI (CI翻译)
This is the hard version of the problem. The difference between the versions is that in this version, the constraint on $x$ and time limit are higher. 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 10$).
第一行包含三个整数 $n$、$q$、$x$,分别表示赛道的平台数量、询问数量以及最大跳跃距离($1 \leq n \leq 10^6$;$1 \leq q \leq 10^4$;$1 \leq x \leq 10$)。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 $i$ $v$" — set the length of the$i$-th platform to$v$($1 \leq i \leq n$;$1 \leq v \leq 10^7$); - "
2 $i$ $y$" — set the penalty on the$i$-th platform to$y$($1 \leq i \leq n$;$1 \leq y \leq 10^5$); - "
? $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 $i$ $v$—— 将第$i$个平台的长度修改为$v$($1 \leq i \leq n$;$1 \leq v \leq 10^7$);2 $i$ $y$—— 将第$i$个平台的罚分修改为$y$($1 \leq i \leq n$;$1 \leq y \leq 10^5$);? $l$ $r$—— 计算通过由编号从$l$到$r$的平台组成的赛道所需的最小罚分($1 \leq l \leq r \leq n$)。
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翻译)
样例
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
11
11
7
7
0
题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。