結果

問題 No.1449 新プロランド
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2021-03-31 15:34:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 190 ms / 2,000 ms
コード長 846 bytes
コンパイル時間 365 ms
コンパイル使用メモリ 87,080 KB
実行使用メモリ 80,052 KB
最終ジャッジ日時 2023-08-25 16:49:02
合計ジャッジ時間 4,074 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,476 KB
testcase_01 AC 75 ms
71,364 KB
testcase_02 AC 76 ms
71,260 KB
testcase_03 AC 76 ms
71,440 KB
testcase_04 AC 75 ms
71,364 KB
testcase_05 AC 125 ms
78,692 KB
testcase_06 AC 77 ms
71,432 KB
testcase_07 AC 76 ms
71,060 KB
testcase_08 AC 91 ms
76,452 KB
testcase_09 AC 74 ms
71,252 KB
testcase_10 AC 75 ms
71,056 KB
testcase_11 AC 76 ms
71,240 KB
testcase_12 AC 129 ms
78,292 KB
testcase_13 AC 75 ms
71,528 KB
testcase_14 AC 74 ms
71,092 KB
testcase_15 AC 74 ms
71,092 KB
testcase_16 AC 77 ms
71,264 KB
testcase_17 AC 91 ms
76,396 KB
testcase_18 AC 74 ms
71,096 KB
testcase_19 AC 75 ms
71,204 KB
testcase_20 AC 74 ms
71,092 KB
testcase_21 AC 76 ms
71,392 KB
testcase_22 AC 76 ms
71,336 KB
testcase_23 AC 75 ms
71,476 KB
testcase_24 AC 74 ms
71,240 KB
testcase_25 AC 73 ms
71,216 KB
testcase_26 AC 74 ms
71,232 KB
testcase_27 AC 190 ms
80,052 KB
testcase_28 AC 99 ms
76,560 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

"""



"""

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,min(1001,np+T[nexv])) )
0