D - Dominoes


  • محدودیت زمان: ۱ ثانیه
  • محدودیت حافظه: ۲۵۶ مگابایت

Pixar is gearing up to introduce its next animated film, Elemental, at the 20232023 Cannes Film Festival. But one of the scenes needs re-rendering. In this scene, there are nn 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 11 month away from the 20232023 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 ii has height lil_i and is located at xix_i. 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 55.

ورودی🔗

The first line of input contains a positive integer nn, indicating the number of dominoes. The next nn lines, each consists of a pair of integers, xix_i and lil_i, indicating the location and the height of the domino number ii. It is guaranteed that n200,000n \leq 200,000 and 1xi1 \leq x_i, li109l_i \leq 10^9. Dominoes are given from left to right; i.e. xi<xi+1x_i < x_{i+1}.

خروجی🔗

Output nn lines, where the ithi-th contains the cost of re-rendering the scene with ithi-th domino as the initial falling domino. All numbers must have an absolute or relative error of at most 10610^{-6}.

مثال🔗

ورودی نمونه ۱🔗

7
2 2
5 3
9 5
12 1
13 5
14 2
16 3
Plain text

خروجی نمونه ۱🔗

3.1415926536
7.0685834706
24.6597736956
0.7853981634
42.2509639206
44.1641868756
49.7141240520
Plain text
ارسال پاسخ برای این سؤال
در حال حاضر شما دسترسی ندارید.