結果
| 問題 |
No.2099 [Cherry Alpha B] Time Machine
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-10-14 21:39:22 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 524 bytes |
| コンパイル時間 | 515 ms |
| コンパイル使用メモリ | 82,176 KB |
| 実行使用メモリ | 450,972 KB |
| 最終ジャッジ日時 | 2024-06-26 13:23:48 |
| 合計ジャッジ時間 | 7,767 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 3 TLE * 3 -- * 66 |
ソースコード
t = int(input())
x,a = map(int,input().split())
y,b = map(int,input().split())
import heapq
#ダイクストラ法
m = 10**7
INF = 10**15
dist = [INF]*(2*m+1)
que = [(0,m)]
dist[m] = 0
while que:
c,crr = heapq.heappop(que)
if c > dist[crr]: continue
if crr == t+m: print(c); exit()
for c,d in [(1,1), (x,a), (y,-b)]:
nxt = crr + d
if nxt >= 2*m+1: continue
if nxt < 0: continue
if dist[crr] + c < dist[nxt]:
dist[nxt] = dist[crr] + c
heapq.heappush(que,(dist[nxt],nxt))
print(dist[t+m])