結果
問題 |
No.1449 新プロランド
|
ユーザー |
|
提出日時 | 2021-03-31 21:50:29 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 390 ms / 2,000 ms |
コード長 | 616 bytes |
コンパイル時間 | 533 ms |
コンパイル使用メモリ | 81,920 KB |
実行使用メモリ | 84,516 KB |
最終ジャッジ日時 | 2024-12-24 02:01:39 |
合計ジャッジ時間 | 6,280 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 |
ソースコード
from heapq import heappush, heappop n,m = map(int,input().split()) e = [[] for i in range(n)] for i in range(m): a,b,c = map(int,input().split()) a -= 1 b -= 1 e[a].append((b,c)) e[b].append((a,c)) T = list(map(int,input().split())) inf = 10**10 dis = [[inf]*(1002) for i in range(n)] h = [(0,0,0)] while h: d,p,now = heappop(h) p *= -1 if dis[now][p] <= d: continue dis[now][p] = d np = min(p+T[now],1001) for nex,c in e[now]: if dis[nex][np] > dis[now][p]+T[now]+c//np: heappush(h, (dis[now][p]+T[now]+c//np,-np,nex)) print(min(dis[-1]))