結果

問題 No.2099 [Cherry Alpha B] Time Machine
コンテスト
ユーザー ntuda
提出日時 2023-12-19 20:25:07
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 548 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 184 ms
コンパイル使用メモリ 85,248 KB
実行使用メモリ 52,352 KB
最終ジャッジ日時 2026-04-14 05:16:27
合計ジャッジ時間 5,565 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 63 WA * 9
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

T = int(input())
X, A = map(int, input().split())
Y, B = map(int, input().split())
ans = 10 ** 15 + 1
tmp = 10 ** 15
y = max(-(T//B),0)
i = 0
ans = tmp
x = (T + B * y) // A
d = (T + B * y) % A
tmp = X * x + Y * y + d
ans = min(ans,tmp)
#print(x, y, d, ans, tmp)
while i < 10:
    if X > Y:
        x += 1
        y = (A * x - T) // B
        d = (A * x - T) % B
    else:
        y += 1
        x = (T + B * y) // A
        d = (T + B * y) % A
    tmp = X * x + Y * y + d
    ans = min(ans, tmp)
    #print(x, y, d, ans, tmp)
    i += 1
print(ans)
0