#Lutece1863. 除草
除草
Migrated from Lutece 1863 除草
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
有 棵草,起始高度均为 0,每棵草每天长高 。有 个除草计划 (, ):在第 天结束后,将所有草超过 的部分除掉,输出除掉部分的总高度和。, , ,保证 递增。
Input
第一行两个数 n, m。第二行 n 个数表示每棵草的生长速度。接下来 m 行,每行两个数,表示计划日和计划高度。
Output
输出 m 行,每行一个数,每个计划的除草量。
Samples
4 4
1 2 4 3
1 1
2 2
3 0
4 3
6
6
18
1
Note
Day | 除草前 | 除草后 | 除草量 |
---|---|---|---|
1 | [1, 2, 4, 3] | [1, 1, 1, 1] | 6 |
2 | [2, 3, 5, 4] | [2, 2, 2, 2] | |
3 | [3, 4, 6, 5] | [0, 0, 0, 0] | 18 |
4 | [1, 2, 4, 3] | [1, 2, 3, 3] | 1 |
Resources
每周一题 Div. 1