結果

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

ソースコード

diff #

t = int(input())
x,a = map(int,input().split())
y,b = map(int,input().split())
import heapq
inf = 10 ** 15
r = max(2*a,2*t)
l = min(-b,t*2)
vis = [inf] * (1 + r - l)
q = [(0,0)]
while q:
    cost,node = heapq.heappop(q)
    if vis[node] <= cost:continue
    vis[node] = cost
    if l <= node + a <= r:
        if vis[node+a] == inf:
            heapq.heappush(q,(cost+x,node + a))
    if l <= node + 1 <= r:
        if vis[node+1] == inf:
            heapq.heappush(q,(cost+1,node + 1))
    if l <= node - b <= r:
        if vis[node-b] == inf:
            heapq.heappush(q,(cost+y,node - b))
#     print(q)
print(vis[t])
0