結果

問題 No.2099 [Cherry Alpha B] Time Machine
ユーザー SidewaysOwlSidewaysOwl
提出日時 2022-10-14 22:54:14
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 534 bytes
コンパイル時間 432 ms
コンパイル使用メモリ 82,688 KB
実行使用メモリ 61,056 KB
最終ジャッジ日時 2024-06-26 16:41:32
合計ジャッジ時間 10,376 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 64 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

t = int(input())
x,a = map(int,input().split())
y,b = map(int,input().split())
ans = 10 ** 15

cnt = 0
while cnt * a <= 3*10**7:
    p_ans = ans
    if cnt * a <= t:
        ans = min(ans,x*cnt + t-a * cnt)
    else:
        ans = min(ans,x*cnt + (-((-(a*cnt-t))//b)) * y +  t - (a*cnt - (-((-(a*cnt-t))//b)) * b))
    cnt += 1

cnt = 0 
b *= -1
while cnt * b >=  - 3*10**7:
    if cnt * b <= t:
        p_ans = ans
        ans = min(ans,y * cnt +  ((t - b*cnt)//a) * x + t - (cnt * b  + ((t - b*cnt)//a) * a))
    cnt += 1
print(ans)
0