문제
Note: the time limit for this problem is 5s, 2.5 times the default. The memory limit is twice the default.
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.
예제 입력 1
5
2 4 3 1 5
3
4 3
1 3
3 2
예제 출력 1
7
10
7
점수
Tests 2-5 satisfy . Tests 6-11 satisfy . Tests 12-21 have no additional constraints.
코드를 제출하려면 로그인이 필요합니다.
로그인