Dominoes | 프로그래밍의 벗 PivotOJ
PivotOJ

Dominoes

시간 제한: 2000ms메모리 제한: 1024MB출처: ICPC Asia Tehran Regional Contest 2022BOJ 28227
이 문제는 본문 이미지 일부가 표시되지 않습니다. 텍스트만으로 풀이가 어려울 수 있습니다.

문제

[이미지 1] Pixar is gearing up to introduce its next animated film, Elemental, at the 2023 Cannes Film Festival. But one of the scenes needs re-rendering. In this scene, there are n dominoes in a straight line, and one of them is supposed to fall and drop a number of subsequent dominoes in a domino-like manner. Considering it is less than 1 month away from the 2023 Cannes Film Festival, Pixar asked you to write a program that calculates the cost of re-rendering the scene for n initial domino choices.

To simplify the calculations, we assume that the dominoes are displayed from the side like line segments with no width on the coordinate axis, and they fall to the left. They are numbered from left to right and domino i has height li and is located at xi. The cost of re-rendering this scene is equal to the area of the moving part of the scene, i.e. the union area of quarter circles of dropped dominoes. Note that domino falling areas may overlap, and the overlapped area should be calculated only once. The picture illustrates the falling of dominoes in the first sample test, when the initial domino choice for falling is the domino number 5.

입력

The first line of input contains a positive integer n, indicating the number of dominoes. The next n lines, each consists of a pair of integers, xi and li, indicating the location and the height of the domino number i. It is guaranteed that n ⩽ 200,000 and 1 ⩽ xi, li ⩽ 109. Dominoes are given from left to right; i.e. xi < xi+1.

출력

Output n lines, where the i-th contains the cost of re-rendering the scene with i-th domino as the initial falling domino. All numbers must have an absolute or relative error of at most 10−6.

예제

예제 1

입력
7
2 2
5 3
9 5
12 1
13 5
14 2
16 3
출력
3.141592654
7.068583471
24.659773696
0.785398163
42.250963921
44.164186876
49.714124052
코드를 제출하려면 로그인하세요.