結果
| 問題 | No.2099 [Cherry Alpha B] Time Machine |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-10-14 21:39:22 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 524 bytes |
| 記録 | |
| コンパイル時間 | 481 ms |
| コンパイル使用メモリ | 85,904 KB |
| 実行使用メモリ | 927,068 KB |
| 最終ジャッジ日時 | 2026-03-13 06:22:31 |
| 合計ジャッジ時間 | 165,427 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 17 TLE * 35 MLE * 20 |
ソースコード
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])