結果

問題 No.450 ベー君のシャトルラン
ユーザー htkbhtkb
提出日時 2018-05-25 19:57:02
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 834 bytes
コンパイル時間 103 ms
コンパイル使用メモリ 10,920 KB
実行使用メモリ 12,708 KB
最終ジャッジ日時 2023-09-11 03:29:30
合計ジャッジ時間 4,779 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,904 KB
testcase_01 AC 16 ms
7,848 KB
testcase_02 AC 16 ms
7,832 KB
testcase_03 AC 16 ms
7,728 KB
testcase_04 AC 16 ms
7,832 KB
testcase_05 AC 15 ms
7,896 KB
testcase_06 AC 16 ms
7,952 KB
testcase_07 AC 17 ms
7,900 KB
testcase_08 AC 16 ms
7,832 KB
testcase_09 AC 16 ms
7,744 KB
testcase_10 AC 16 ms
7,948 KB
testcase_11 AC 16 ms
7,828 KB
testcase_12 AC 16 ms
7,768 KB
testcase_13 AC 16 ms
7,792 KB
testcase_14 AC 16 ms
7,912 KB
testcase_15 AC 16 ms
7,824 KB
testcase_16 AC 16 ms
7,936 KB
testcase_17 AC 17 ms
7,848 KB
testcase_18 AC 17 ms
7,808 KB
testcase_19 AC 16 ms
7,756 KB
testcase_20 AC 17 ms
7,724 KB
testcase_21 TLE -
testcase_22 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

vl, vr = map(int, input().split())
d = int(input())
w = int(input())
l_pos, r_pos, bee_pos = 0, d, 0
distance = 0

while (r_pos-l_pos) > 1e-8:
    ok, ng = 0, (r_pos-bee_pos)
    while (ng-ok) > 1e-12:
        mid = (ok+ng) / 2
        b, t = bee_pos+mid*w, r_pos-mid*vr
        if b <= t:
            ok = mid
        else:
            ng = mid

    bee_pos += mid * w
    r_pos -= mid * vr
    l_pos += mid * vl
    distance += mid * w
    #print(distance, l_pos, bee_pos, r_pos)

    ok, ng = 0, (bee_pos-l_pos)
    while (ng-ok) > 1e-12:
        mid = (ok+ng) / 2
        b, t = bee_pos-(mid*w), l_pos+mid*vl
        if t <= b:
            ok = mid
        else:
            ng = mid

    bee_pos -= mid*w
    r_pos -= mid*vr
    l_pos += mid * vl
    distance += mid*w
    #print(distance, l_pos, bee_pos, r_pos)

print(distance)
0