結果

問題 No.2099 [Cherry Alpha B] Time Machine
ユーザー nikumakare
提出日時 2022-10-14 21:31:58
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
実行時間 -
コード長 560 bytes
コンパイル時間 590 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 153,984 KB
最終ジャッジ日時 2024-06-26 13:14:45
合計ジャッジ時間 3,946 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 3 TLE * 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