結果
| 問題 |
No.2099 [Cherry Alpha B] Time Machine
|
| コンテスト | |
| ユーザー |
SidewaysOwl
|
| 提出日時 | 2022-10-14 21:44:03 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 654 bytes |
| コンパイル時間 | 311 ms |
| コンパイル使用メモリ | 82,340 KB |
| 実行使用メモリ | 239,548 KB |
| 最終ジャッジ日時 | 2024-06-26 13:33:51 |
| 合計ジャッジ時間 | 4,125 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 3 TLE * 1 -- * 68 |
ソースコード
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 vis[t] != inf :break
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])
SidewaysOwl