結果
問題 | No.1449 新プロランド |
ユーザー | 👑 SPD_9X2 |
提出日時 | 2021-03-31 15:33:52 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 180 ms / 2,000 ms |
コード長 | 848 bytes |
コンパイル時間 | 200 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 78,000 KB |
最終ジャッジ日時 | 2024-12-24 01:55:39 |
合計ジャッジ時間 | 2,870 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 |
ソースコード
""" """ import sys from sys import stdin import heapq N,M = map(int,stdin.readline().split()) lis = [ [] for i in range(N) ] for i in range(M): A,B,C = map(int,stdin.readline().split()) A -= 1 B -= 1 lis[A].append( (B,C) ) lis[B].append( (A,C) ) T = list(map(int,stdin.readline().split())) dp = [[float("inf")] * 1002 for i in range(N)] dp[0][T[0]] = T[0] q = [] heapq.heappush( q , (T[0] , 0 , T[0]) ) while q: ncost , nv , np = heapq.heappop(q) if dp[nv][np] != ncost: continue if nv == N-1: print (ncost) sys.exit() for nexv,ecost in lis[nv]: nexcost = ncost + ecost // np + T[nexv] if dp[nexv][min(1001,np+T[nexv])] > nexcost: dp[nexv][min(1001,np+T[nexv])] = nexcost heapq.heappush(q , (nexcost,nexv,np+T[nexv]) )