結果

問題 No.1449 新プロランド
ユーザー 👑 rin204rin204
提出日時 2023-08-25 23:49:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 276 ms / 2,000 ms
コード長 658 bytes
コンパイル時間 298 ms
コンパイル使用メモリ 87,032 KB
実行使用メモリ 82,392 KB
最終ジャッジ日時 2023-08-25 23:49:45
合計ジャッジ時間 5,961 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
75,980 KB
testcase_01 AC 98 ms
77,836 KB
testcase_02 AC 116 ms
77,756 KB
testcase_03 AC 80 ms
76,396 KB
testcase_04 AC 107 ms
77,856 KB
testcase_05 AC 276 ms
82,392 KB
testcase_06 AC 270 ms
81,200 KB
testcase_07 AC 151 ms
78,960 KB
testcase_08 AC 232 ms
80,824 KB
testcase_09 AC 161 ms
78,984 KB
testcase_10 AC 175 ms
78,920 KB
testcase_11 AC 138 ms
79,032 KB
testcase_12 AC 243 ms
80,488 KB
testcase_13 AC 178 ms
78,912 KB
testcase_14 AC 126 ms
78,484 KB
testcase_15 AC 236 ms
81,696 KB
testcase_16 AC 181 ms
79,672 KB
testcase_17 AC 189 ms
79,104 KB
testcase_18 AC 68 ms
71,152 KB
testcase_19 AC 77 ms
71,444 KB
testcase_20 AC 67 ms
71,364 KB
testcase_21 AC 133 ms
78,116 KB
testcase_22 AC 137 ms
78,960 KB
testcase_23 AC 157 ms
79,204 KB
testcase_24 AC 150 ms
78,008 KB
testcase_25 AC 64 ms
71,036 KB
testcase_26 AC 94 ms
77,456 KB
testcase_27 AC 250 ms
81,556 KB
testcase_28 AC 216 ms
79,356 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import *

n, m = map(int, input().split())
edges = [[] for _ in range(n)]
for _ in range(m):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    edges[a].append((b, c))
    edges[b].append((a, c))
T = list(map(int, input().split()))
inf = 1 << 60
dist = [[inf] * 1002 for _ in range(n)]
dist[0][0] = 0
hq = [(0, 0, 0)]
while hq:
    d, pos, p = heappop(hq)
    if dist[pos][p] < d:
        continue
    p += T[pos]
    p = min(p, 1001)
    d += T[pos]
    for npos, c in edges[pos]:
        tmp = d + c // p
        if dist[npos][p] > tmp:
            dist[npos][p] = tmp
            heappush(hq, (tmp, npos, p))
print(min(dist[-1]))
0