結果

問題 No.2099 [Cherry Alpha B] Time Machine
ユーザー gew1fw
提出日時 2025-06-12 13:59:32
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 640 bytes
コンパイル時間 231 ms
コンパイル使用メモリ 82,492 KB
実行使用メモリ 53,988 KB
最終ジャッジ日時 2025-06-12 14:00:16
合計ジャッジ時間 4,608 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 54 WA * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

T = int(input())
X, A = map(int, input().split())
Y, B = map(int, input().split())

if T < 0:
    required_b = (-T + B - 1) // B
    cost = T + required_b * (Y + B)
    print(cost)
else:
    initial_cost = T
    a_floor = T // A
    a_candidates = [0, a_floor, a_floor + 1, a_floor + 2]
    min_cost = initial_cost

    for a in a_candidates:
        if a < 0:
            continue
        if a * A > T:
            D = a * A - T
            b = (D + B - 1) // B
        else:
            b = 0
        current_cost = T + a * (X - A) + b * (Y + B)
        if current_cost < min_cost:
            min_cost = current_cost

    print(min_cost)
0