結果

問題 No.1449 新プロランド
ユーザー titia
提出日時 2025-04-08 03:48:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 316 ms / 2,000 ms
コード長 700 bytes
コンパイル時間 509 ms
コンパイル使用メモリ 82,528 KB
実行使用メモリ 80,500 KB
最終ジャッジ日時 2025-04-08 03:49:03
合計ジャッジ時間 6,244 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

from heapq import heappop,heappush

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()))

DP=[[1<<60]*N for i in range(1050)]
DP[0][0]=0

Q=[(0,0,0)]

while Q:
    dis,eat,town=heappop(Q)

    if DP[eat][town]!=dis:
        continue

    eat=min(1049,eat+T[town])

    for to,cost in E[town]:

        if DP[eat][to]>dis+cost//eat+T[town]:
            DP[eat][to]=dis+cost//eat+T[town]
            heappush(Q,(DP[eat][to],eat,to))

ANS=1<<60

for i in range(1050):
    ANS=min(ANS,DP[i][N-1])

print(ANS)
0