結果

問題 No.1449 新プロランド
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2021-03-31 21:50:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 440 ms / 2,000 ms
コード長 616 bytes
コンパイル時間 525 ms
コンパイル使用メモリ 87,292 KB
実行使用メモリ 86,912 KB
最終ジャッジ日時 2023-08-25 16:51:16
合計ジャッジ時間 7,549 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
76,412 KB
testcase_01 AC 119 ms
77,732 KB
testcase_02 AC 156 ms
78,444 KB
testcase_03 AC 108 ms
77,988 KB
testcase_04 AC 125 ms
77,904 KB
testcase_05 AC 394 ms
85,200 KB
testcase_06 AC 301 ms
82,304 KB
testcase_07 AC 211 ms
79,628 KB
testcase_08 AC 299 ms
82,448 KB
testcase_09 AC 332 ms
83,040 KB
testcase_10 AC 218 ms
79,832 KB
testcase_11 AC 154 ms
78,988 KB
testcase_12 AC 274 ms
81,968 KB
testcase_13 AC 270 ms
79,812 KB
testcase_14 AC 159 ms
79,492 KB
testcase_15 AC 287 ms
81,232 KB
testcase_16 AC 251 ms
80,888 KB
testcase_17 AC 276 ms
80,752 KB
testcase_18 AC 77 ms
71,500 KB
testcase_19 AC 76 ms
71,340 KB
testcase_20 AC 76 ms
71,344 KB
testcase_21 AC 199 ms
80,356 KB
testcase_22 AC 160 ms
78,980 KB
testcase_23 AC 182 ms
79,356 KB
testcase_24 AC 235 ms
79,200 KB
testcase_25 AC 75 ms
71,480 KB
testcase_26 AC 103 ms
77,288 KB
testcase_27 AC 440 ms
86,912 KB
testcase_28 AC 395 ms
83,684 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import heappush, heappop
n,m = map(int,input().split())

e = [[] for i in range(n)]
for i in range(m):
    a,b,c = map(int,input().split())
    a -= 1
    b -= 1
    e[a].append((b,c))
    e[b].append((a,c))
T = list(map(int,input().split()))

inf = 10**10
dis = [[inf]*(1002) for i in range(n)]

h = [(0,0,0)]
while h:
    d,p,now = heappop(h)
    p *= -1
    if dis[now][p] <= d:
        continue
    dis[now][p] = d
    np = min(p+T[now],1001)
    for nex,c in e[now]:

        if dis[nex][np] > dis[now][p]+T[now]+c//np:
            heappush(h, (dis[now][p]+T[now]+c//np,-np,nex))
print(min(dis[-1]))
0