結果
| 問題 |
No.764 浮動点
|
| コンテスト | |
| ユーザー |
maspy
|
| 提出日時 | 2020-04-15 20:39:54 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 37 ms / 1,500 ms |
| コード長 | 1,375 bytes |
| コンパイル時間 | 269 ms |
| コンパイル使用メモリ | 12,928 KB |
| 実行使用メモリ | 11,264 KB |
| 最終ジャッジ日時 | 2024-10-01 19:01:49 |
| 合計ジャッジ時間 | 2,279 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
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))
maspy