結果

問題 No.1449 新プロランド
ユーザー lloyzlloyz
提出日時 2022-08-21 14:58:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 351 ms / 2,000 ms
コード長 754 bytes
コンパイル時間 312 ms
コンパイル使用メモリ 87,100 KB
実行使用メモリ 82,828 KB
最終ジャッジ日時 2023-08-25 16:54:06
合計ジャッジ時間 6,993 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 94 ms
71,560 KB
testcase_01 AC 93 ms
71,512 KB
testcase_02 AC 154 ms
78,428 KB
testcase_03 AC 115 ms
77,488 KB
testcase_04 AC 144 ms
78,344 KB
testcase_05 AC 351 ms
82,828 KB
testcase_06 AC 312 ms
81,512 KB
testcase_07 AC 191 ms
79,576 KB
testcase_08 AC 295 ms
81,556 KB
testcase_09 AC 206 ms
79,364 KB
testcase_10 AC 212 ms
80,100 KB
testcase_11 AC 169 ms
79,408 KB
testcase_12 AC 260 ms
80,848 KB
testcase_13 AC 201 ms
79,372 KB
testcase_14 AC 147 ms
78,856 KB
testcase_15 AC 269 ms
81,280 KB
testcase_16 AC 222 ms
79,876 KB
testcase_17 AC 236 ms
80,308 KB
testcase_18 AC 97 ms
76,696 KB
testcase_19 AC 97 ms
76,340 KB
testcase_20 AC 96 ms
76,500 KB
testcase_21 AC 169 ms
78,976 KB
testcase_22 AC 165 ms
78,964 KB
testcase_23 AC 204 ms
79,536 KB
testcase_24 AC 196 ms
78,700 KB
testcase_25 AC 99 ms
76,408 KB
testcase_26 AC 94 ms
71,624 KB
testcase_27 AC 318 ms
82,232 KB
testcase_28 AC 247 ms
80,284 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import heapify, heappop, heappush
from collections import defaultdict

n, m = map(int, input().split())
edge = defaultdict(list)
max_c = 0
for _ in range(m):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    max_c = max(max_c, c)
    edge[a].append((b, c))
    edge[b].append((a, c))
T = list(map(int, input().split()))

INF = 10**18
D = [[INF for _ in range(max_c + 2)] for _ in range(n)]
D[0][0] = 0

H = [(0, 0, 0)]
heapify(H)
while H:
    t, cp, et = heappop(H)
    if D[cp][et] < t:
        continue
    t += T[cp]
    et = min(et + T[cp], max_c + 1)
    for np, tt in edge[cp]:
        if D[np][et] > t + tt // et:
            D[np][et] = t + tt // et
            heappush(H, (t + tt // et, np, et))
print(min(D[n - 1]))
0