結果

問題 No.1449 新プロランド
ユーザー gorugo30gorugo30
提出日時 2021-05-08 17:37:09
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 327 ms / 2,000 ms
コード長 742 bytes
コンパイル時間 347 ms
コンパイル使用メモリ 86,968 KB
実行使用メモリ 82,696 KB
最終ジャッジ日時 2023-08-25 16:53:17
合計ジャッジ時間 6,844 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
76,352 KB
testcase_01 AC 120 ms
77,360 KB
testcase_02 AC 149 ms
77,860 KB
testcase_03 AC 95 ms
76,568 KB
testcase_04 AC 124 ms
77,544 KB
testcase_05 AC 327 ms
82,696 KB
testcase_06 AC 273 ms
80,796 KB
testcase_07 AC 178 ms
79,080 KB
testcase_08 AC 296 ms
81,572 KB
testcase_09 AC 231 ms
79,868 KB
testcase_10 AC 229 ms
80,308 KB
testcase_11 AC 170 ms
79,320 KB
testcase_12 AC 260 ms
80,472 KB
testcase_13 AC 198 ms
78,920 KB
testcase_14 AC 141 ms
78,244 KB
testcase_15 AC 287 ms
81,268 KB
testcase_16 AC 230 ms
79,424 KB
testcase_17 AC 253 ms
80,736 KB
testcase_18 AC 77 ms
71,100 KB
testcase_19 AC 76 ms
71,080 KB
testcase_20 AC 76 ms
71,244 KB
testcase_21 AC 182 ms
78,900 KB
testcase_22 AC 162 ms
79,012 KB
testcase_23 AC 180 ms
79,212 KB
testcase_24 AC 204 ms
78,780 KB
testcase_25 AC 78 ms
71,228 KB
testcase_26 AC 106 ms
77,652 KB
testcase_27 AC 287 ms
81,492 KB
testcase_28 AC 238 ms
80,028 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, M = map(int, input().split())
adj = [[] for i in range(N)]
for i in range(M):
    A, B, C = map(int, input().split())
    A -= 1
    B -= 1
    adj[A].append((B, C))
    adj[B].append((A, C))
T = list(map(int, input().split()))

dist = [[-1] * 1002 for i in range(N)]
dist[0][0] = 0
import heapq
pq = [(0, 0, 0)]
while len(pq):
    d, v, p = heapq.heappop(pq)
    if d > dist[v][p]:
        continue
    for nv, c in adj[v]:
        np = min(1001, T[v] + p)
        nd = d + T[v] + c // np
        if dist[nv][np] == -1 or dist[nv][np] > nd:
            dist[nv][np] = nd
            heapq.heappush(pq, (nd, nv, np))
ans = 10 ** 10
for i in range(1002):
    if dist[-1][i] == -1:
        continue
    ans = min(ans, dist[-1][i])
print(ans)
0