結果

問題 No.764 浮動点
ユーザー maspymaspy
提出日時 2020-04-15 20:39:54
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 35 ms / 1,500 ms
コード長 1,375 bytes
コンパイル時間 91 ms
コンパイル使用メモリ 12,928 KB
実行使用メモリ 11,392 KB
最終ジャッジ日時 2024-04-09 18:58:55
合計ジャッジ時間 1,845 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
11,008 KB
testcase_01 AC 26 ms
10,880 KB
testcase_02 AC 27 ms
10,880 KB
testcase_03 AC 29 ms
11,264 KB
testcase_04 AC 30 ms
11,264 KB
testcase_05 AC 32 ms
11,264 KB
testcase_06 AC 34 ms
11,392 KB
testcase_07 AC 29 ms
11,136 KB
testcase_08 AC 29 ms
11,264 KB
testcase_09 AC 28 ms
11,264 KB
testcase_10 AC 31 ms
11,264 KB
testcase_11 AC 28 ms
11,136 KB
testcase_12 AC 30 ms
11,136 KB
testcase_13 AC 31 ms
11,136 KB
testcase_14 AC 33 ms
11,392 KB
testcase_15 AC 32 ms
11,264 KB
testcase_16 AC 32 ms
11,392 KB
testcase_17 AC 35 ms
11,264 KB
testcase_18 AC 30 ms
11,136 KB
testcase_19 AC 30 ms
11,136 KB
testcase_20 AC 32 ms
11,136 KB
testcase_21 AC 32 ms
11,136 KB
testcase_22 AC 34 ms
11,136 KB
testcase_23 AC 31 ms
11,136 KB
testcase_24 AC 31 ms
11,136 KB
testcase_25 AC 27 ms
11,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from math import acos, cos, sin, pi

N, L0, *L = map(int, read().split())

from_left = [(0, 0)] * N
from_right = [(0, 0)] * N

low = 0
high = 0
for i, x in enumerate(L[:-1]):
    if low <= x <= high:
        low = 0
    else:
        low = min(abs(low - x), abs(high - x))
    high = high + x
    from_left[i] = (low, high)

low = 0
high = 0
for i, x in enumerate(L[::-1][:-1]):
    if low <= x <= high:
        low = 0
    else:
        low = min(abs(low - x), abs(high - x))
    high = high + x
    from_right[i] = (low, high)
from_right = from_right[::-1]


def common_area(L, R1, R2):
    if R1 > R2:
        R1, R2 = R2, R1
    if R1 + R2 <= L:
        return 0
    if L + R1 <= R2:
        return R1 * R1 * pi
    # 2点で交わる場合
    theta_1 = acos((R1 * R1 + L * L - R2 * R2) / (2 * R1 * L))
    theta_2 = acos((R2 * R2 + L * L - R1 * R1) / (2 * R2 * L))

    S = R1 * R1 * (theta_1 - sin(theta_1) * cos(theta_1))
    S += R2 * R2 * (theta_2 - sin(theta_2) * cos(theta_2))
    return S


def f(L, r1, R1, r2, R2):
    S = common_area(L, R1, R2)
    S -= common_area(L, r1, R2)
    S -= common_area(L, R1, r2)
    S += common_area(L, r1, r2)
    return S


for (r1, R1), (r2, R2) in zip(from_left, from_right):
    print(f(L0, r1, R1, r2, R2))
0