結果

問題 No.2099 [Cherry Alpha B] Time Machine
ユーザー SidewaysOwl
提出日時 2022-10-14 22:09:54
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 611 bytes
コンパイル時間 1,678 ms
コンパイル使用メモリ 82,468 KB
実行使用メモリ 60,992 KB
最終ジャッジ日時 2024-06-26 14:48:02
合計ジャッジ時間 6,265 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 52 WA * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

t = int(input())
x,a = map(int,input().split())
y,b = map(int,input().split())
ans = 10 ** 15
if t >= 0:
    cnt = 0
    while cnt * a <= 2*10**7:
        if cnt * a <= t:
            ans = min(ans,x*cnt + t-x * cnt)
        else:
#             print(a*cnt,-((-(a*cnt-t))//b))
            ans = min(ans,x*cnt + (-((-(a*cnt-t))//b)) * y +  t - (a*cnt - (-((-(a*cnt-t))//b)) * b))
        cnt += 1
else:
    cnt = 0 
    b *= -1
    while cnt * b >=  - 2*10**7:
        if cnt * b <= t:
            ans = min(ans,y * cnt +  ((t - b*cnt)//a) * x + t - (cnt * b  + ((t - b*cnt)//a) * a))
        cnt += 1
print(ans)
0