Mountains
시간 제한5초메모리 제한1024 MB
산의 높이가 오를 때마다 두 산봉우리를 잇는 선분을 가리는 산이 없는 쌍의 개수를 센다.
문제
There are () evenly spaced mountains in a row on the edge of Farmer John's farm. These can be expressed as an array of heights . For a mountain , you can see another mountain if there are no mountains strictly higher than the line of sight connecting the tops of mountain and . Formally, for two mountains , they can see each other if there is no such that and is above the line segment connecting and . There are () updates where the height of one mountain increases. Find the total number of unordered pairs of mountains that see each other after each update.
입력
Line contains .
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 .
출력
lines, with the total number of unordered pairs of mountains that see each other after each update.
힌트
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 .