結果

問題 No.2010 Magical Floor
ユーザー 👑 rin204rin204
提出日時 2022-07-15 22:30:51
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,098 bytes
コンパイル時間 264 ms
コンパイル使用メモリ 87,256 KB
実行使用メモリ 80,360 KB
最終ジャッジ日時 2023-09-10 03:16:31
合計ジャッジ時間 11,141 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,696 KB
testcase_01 AC 79 ms
71,692 KB
testcase_02 AC 117 ms
77,632 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve():
    n, x = map(int, input().split())
    H = list(map(int, input().split()))
    A = list(map(int, input().split()))
    ans = x * A[0]
    z = x / 2
    h = H[0]
    a = (h * h + 1) ** 0.5 * A[0]
    for h2, b in zip(H[1:], A[1:]):
        f = lambda x:((h * h + x * x) / (h * h + 1)) ** 0.5 * a + (z - x) * b
        l = 0
        r = z
        for _ in range(100):
            llr = (2 * l + r) / 3
            lrr = (l + 2 * r) / 3
            if f(llr) < f(lrr):
                r = lrr
            else:
                l = llr
        tmp = 2 * min(f(l), f(llr), f(lrr), f(r))
        ans = min(ans, tmp)
        f = lambda x:((h * h + x * x) / (h * h + 1)) ** 0.5 * a + (h2 * h2 + (1 - x) ** 2) ** 0.5 * b
        l = 0
        r = 1
        for _ in range(100):
            llr = (2 * l + r) / 3
            lrr = (l + 2 * r) / 3
            if f(llr) < f(lrr):
                r = lrr
            else:
                l = llr
        tmp = min(f(l), f(llr), f(lrr), f(r))
        a = tmp
        h += h2


    print(ans)

        


for _ in range(int(input())):
    solve()
0