当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

7238:Mario Party

题目描述
Mario Party is a classic board game featuring numerous minigames. In this game, players possess coins and aim to collect stars at particular positions. For simplicity, we treat the board as a $1$ by $n$ grid with grids labeled with $1$ to $n$ from left to right, and there is an integer $a_i$ in cell $i$. Suppose a player is currently in the cell $i$ with $x$ coins. He may perform the following operation:
<ol>
<li> Move to cell $i+1$, and the number of coins he possesses becomes $x + a_{i+1}$ if $x+a_{i+1} \ge 0$, and remains the same otherwise . </li>
</ol>

You have to answer $q$ independent queries of the following form:
<ol>
<li> Suppose a player is currently in cell $l$ with $x$ coins. Compute the number of coins he possesses after he travels to cell $r$ by performing the above operations $r-l$ times. </li>
</ol>
输入解释
The first line contains an integer $T$ ($1 \le T \le 4$), denoting the number of test cases.

For each test case, the first line contains two integers $n,q$ ($1 \le n,q \le 5 \cdot 10^5$), denoting the number of cells in the grid and the number of queries, respectively.

The second line of each test case contains $n$ integers $a_1,a_2,\ldots,a_n$ ($\sum_{i=1}^n |a_i| \le 10^6$).

Each of the following $q$ lines contains integers $l_i,r_i,x_i$ ($1 \le l_i \le r_i \le n$, $0 \le x_i \le 10^{6}$), denoting the parameters of the $i$-th query.

输出解释
For each query in each test case, output an integer in one line, denoting the answer.
输入样例
1
5 6
1 -2 3 -4 5
1 5 0
1 5 1
1 5 2
1 5 3
1 5 4
1 5 5
输出样例
8
5
8
5
6
7

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-7238

最后修改于 2022-09-15T06:17:34+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
40000/20000MS(Java/Others) 524288/524288K(Java/Others)