結果

問題 No.2099 [Cherry Alpha B] Time Machine
ユーザー nikumakare
提出日時 2022-10-14 21:31:07
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 560 bytes
コンパイル時間 201 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 591,776 KB
最終ジャッジ日時 2024-06-26 13:13:46
合計ジャッジ時間 3,991 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 3 MLE * 1 -- * 68
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq

t=int(input())
x,a=map(int,input().split())
y,b=map(int,input().split())

V={0}

que=[(0,0)]
heapq.heapify(que)

MAX=10**7+100
while 1:
    val,now=heapq.heappop(que)
    if now==t:
        print(val)
        break

    vx=now+a
    if abs(vx)<2*MAX and not vx in V:
        heapq.heappush(que,(val+x,vx))
        V.add(vx)
    
    vx=now-b
    if abs(vx)<2*MAX and not vx in V:
        heapq.heappush(que,(val+y,vx))
        V.add(vx)

    vx=now+1
    if abs(vx)<2*MAX and not vx in V:
        heapq.heappush(que,(val+1,vx))
        V.add(vx)
0