結果

問題 No.1449 新プロランド
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2021-03-31 15:33:52
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 186 ms / 2,000 ms
コード長 848 bytes
コンパイル時間 274 ms
コンパイル使用メモリ 87,048 KB
実行使用メモリ 79,216 KB
最終ジャッジ日時 2023-08-25 16:49:05
合計ジャッジ時間 3,944 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,168 KB
testcase_01 AC 76 ms
71,488 KB
testcase_02 AC 79 ms
71,580 KB
testcase_03 AC 75 ms
71,544 KB
testcase_04 AC 76 ms
71,500 KB
testcase_05 AC 125 ms
78,944 KB
testcase_06 AC 76 ms
71,332 KB
testcase_07 AC 75 ms
71,452 KB
testcase_08 AC 92 ms
76,540 KB
testcase_09 AC 76 ms
71,244 KB
testcase_10 AC 73 ms
71,048 KB
testcase_11 AC 75 ms
71,588 KB
testcase_12 AC 130 ms
78,400 KB
testcase_13 AC 74 ms
71,300 KB
testcase_14 AC 73 ms
71,288 KB
testcase_15 AC 75 ms
71,576 KB
testcase_16 AC 76 ms
71,380 KB
testcase_17 AC 93 ms
76,592 KB
testcase_18 AC 75 ms
71,200 KB
testcase_19 AC 76 ms
71,580 KB
testcase_20 AC 76 ms
71,376 KB
testcase_21 AC 75 ms
71,228 KB
testcase_22 AC 76 ms
71,272 KB
testcase_23 AC 77 ms
71,408 KB
testcase_24 AC 76 ms
71,488 KB
testcase_25 AC 75 ms
71,460 KB
testcase_26 AC 74 ms
71,224 KB
testcase_27 AC 186 ms
79,216 KB
testcase_28 AC 98 ms
76,624 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,np+T[nexv]) )


        
0