1976: [USACO 2022 December Contest Gold] Problem 2. Mountains
题目描述
输入
Line contains heights (for each , ).
Line contains .
Lines to contain , (, ) where is the index of the mountain and is the amount the height increases by. It is guaranteed that the new height of the mountain is at most .
输出
样例输入
5
2 4 3 1 5
3
4 3
1 3
3 2
样例输出
7
10
7
提示
Initially, the following pairs of mountains can see each other: , , , , (, , a total of .
After the first update, mountain has a height of , which doesn't block any visibility but does make it so that can now see , making the new answer .
After the second update, mountain has a height of , which doesn't block any visibility but does make it so that
can now see , , and , making the new answer .After the third update, mountain has a height of , which blocks mountain from seeing mountain , blocks mountain from seeing mountains and , and doesn't allow itself to see any more mountains since it can already see all of them, making the new answer .
SCORING:
- Tests 2-5 satisfy .
- Tests 6-11 satisfy .
- Tests 12-21 have no additional constraints.