結果

問題 No.1449 新プロランド
ユーザー 👑 rin204rin204
提出日時 2023-08-25 23:44:37
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 669 bytes
コンパイル時間 799 ms
コンパイル使用メモリ 86,820 KB
実行使用メモリ 82,296 KB
最終ジャッジ日時 2023-08-25 23:44:45
合計ジャッジ時間 6,802 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
76,308 KB
testcase_01 AC 100 ms
77,684 KB
testcase_02 AC 118 ms
77,348 KB
testcase_03 AC 78 ms
76,200 KB
testcase_04 AC 106 ms
77,308 KB
testcase_05 AC 288 ms
82,296 KB
testcase_06 AC 259 ms
81,468 KB
testcase_07 AC 179 ms
78,404 KB
testcase_08 AC 241 ms
80,536 KB
testcase_09 AC 169 ms
78,832 KB
testcase_10 AC 181 ms
79,352 KB
testcase_11 AC 148 ms
78,984 KB
testcase_12 AC 235 ms
80,644 KB
testcase_13 AC 179 ms
78,616 KB
testcase_14 AC 137 ms
78,604 KB
testcase_15 AC 242 ms
81,372 KB
testcase_16 AC 190 ms
79,808 KB
testcase_17 AC 197 ms
79,464 KB
testcase_18 AC 67 ms
71,024 KB
testcase_19 AC 66 ms
71,268 KB
testcase_20 AC 66 ms
71,032 KB
testcase_21 AC 134 ms
78,408 KB
testcase_22 AC 169 ms
79,236 KB
testcase_23 AC 168 ms
78,480 KB
testcase_24 AC 172 ms
78,540 KB
testcase_25 WA -
testcase_26 AC 91 ms
77,140 KB
testcase_27 AC 264 ms
81,576 KB
testcase_28 AC 205 ms
79,760 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 = min(d + c // p, 1000)
        if dist[npos][p] > tmp:
            dist[npos][p] = tmp
            heappush(hq, (tmp, npos, p))
print(min(dist[-1]))
0