結果

問題 No.1449 新プロランド
ユーザー 👑 rin204rin204
提出日時 2022-01-18 04:51:30
言語 PyPy3
(7.3.15)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 669 bytes
コンパイル時間 297 ms
コンパイル使用メモリ 87,020 KB
実行使用メモリ 82,756 KB
最終ジャッジ日時 2023-08-25 16:53:42
合計ジャッジ時間 6,628 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
76,308 KB
testcase_01 AC 111 ms
77,432 KB
testcase_02 AC 136 ms
77,648 KB
testcase_03 AC 90 ms
76,448 KB
testcase_04 AC 118 ms
77,752 KB
testcase_05 AC 319 ms
82,756 KB
testcase_06 AC 290 ms
81,520 KB
testcase_07 AC 172 ms
78,620 KB
testcase_08 AC 276 ms
80,832 KB
testcase_09 AC 187 ms
79,144 KB
testcase_10 AC 205 ms
79,620 KB
testcase_11 AC 165 ms
79,708 KB
testcase_12 AC 258 ms
80,720 KB
testcase_13 AC 201 ms
78,736 KB
testcase_14 AC 140 ms
78,704 KB
testcase_15 AC 270 ms
81,200 KB
testcase_16 AC 212 ms
79,948 KB
testcase_17 AC 223 ms
79,348 KB
testcase_18 AC 77 ms
71,380 KB
testcase_19 AC 75 ms
71,144 KB
testcase_20 AC 76 ms
71,440 KB
testcase_21 AC 153 ms
78,616 KB
testcase_22 AC 162 ms
79,192 KB
testcase_23 AC 185 ms
79,140 KB
testcase_24 AC 189 ms
79,236 KB
testcase_25 WA -
testcase_26 AC 105 ms
77,508 KB
testcase_27 AC 298 ms
81,660 KB
testcase_28 AC 228 ms
80,204 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] * 1001 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, 1000)
    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