CF2185D.OFME
普及-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Bessie has an array of n integers a1,a2,…,an. Bessie performs m operations on the array. The i-th operation sets abi=abi+ci.
Unfortunately, due to rising RAM costs, Bessie's computer has limited memory, and whenever any element of the array is greater than h, her computer crashes, and every element in the array is reset to its original value.
After all operations have been performed, output the array a.
贝茜有一个包含 n 个整数的数组 a1,a2,…,an。贝茜对该数组执行 m 次操作。第 i 次操作将 abi 更新为 abi+ci。
不幸的是,由于内存成本不断上涨,贝茜的计算机内存有限:每当数组中任意元素的值超过 h 时,她的计算机会崩溃,并将数组中所有元素重置为初始值。
在完成所有操作后,请输出最终的数组 a。
输入格式
The first line of the input contains a single integer t (1≤t≤104) — the number of test cases.
The first line of each test case contains three integers n,m,h (1≤n,m≤2⋅105, 1≤h≤109) — the length of array a, the number of operations performed, and the maximum value that Bessie's computer can store without crashing.
The second line contains n integers a1,a2,…,an (0≤ai≤h) — the array a.
The next m lines contain two integers bi,ci (1≤bi≤n, 0≤ci≤109) — the operations that Bessie performs on the array.
It is guaranteed that the sum of n and the sum of m over all test cases does not exceed 2⋅105.
输入的第一行包含一个整数 t(1≤t≤104),表示测试用例的数量。
每个测试用例的第一行包含三个整数 n,m,h(1≤n,m≤2⋅105,1≤h≤109),分别表示数组 a 的长度、执行的操作次数,以及 Bessie 的计算机在不崩溃的情况下所能存储的最大值。
第二行包含 n 个整数 a1,a2,…,an(0≤ai≤h),即数组 a。
接下来的 m 行每行包含两个整数 bi,ci(1≤bi≤n,0≤ci≤109),表示 Bessie 对数组执行的操作。
保证所有测试用例中 n 的总和与 m 的总和均不超过 2⋅105。
输出格式
For each test case, output the array a after all operations have been performed.
对于每个测试用例,输出执行完所有操作后的数组 a。
输入输出样例
输入#1
3 3 4 5 1 2 1 1 4 2 4 3 3 2 0 5 3 1 1 1 1 1 1 1 1 1 1 2 1 4 4 1 1 0 0 0 1 1 4 4 3 3 4 4
输出#1
1 2 4 1 1 1 1 1 1 0 0 0
说明/提示
For the first test case, the array a is changed as follows:
- Before all operations, a=[1,2,1].
- After the first operation, a=[5,2,1].
- After the second operation, a=[5,6,1], but since 6>h, the computer crashes, and a=[1,2,1].
- After the third operation, a=[1,2,4].
- After the fourth operation, a=[1,2,4].
For the third test case, each operation causes the computer to crash, so a=[1,0,0,0].
对于第一个测试用例,数组 a 的变化过程如下:
- 所有操作之前,a=[1,2,1]。
- 第一次操作后,a=[5,2,1]。
- 第二次操作后,a=[5,6,1],但由于 6>h,计算机崩溃,因此 a 恢复为 [1,2,1]。
- 第三次操作后,a=[1,2,4]。
- 第四次操作后,a=[1,2,4]。
对于第三个测试用例,每次操作均导致计算机崩溃,因此 a=[1,0,0,0]。
输入解题思路,AI测评打分。不知道怎么写?