結果

問題 No.1449 新プロランド
ユーザー shiomusubi496shiomusubi496
提出日時 2021-03-25 09:55:44
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 215 ms / 2,000 ms
コード長 547 bytes
コンパイル時間 1,037 ms
コンパイル使用メモリ 10,784 KB
実行使用メモリ 11,140 KB
最終ジャッジ日時 2023-08-25 16:44:48
合計ジャッジ時間 4,317 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
8,060 KB
testcase_01 AC 25 ms
8,064 KB
testcase_02 AC 37 ms
8,440 KB
testcase_03 AC 18 ms
8,080 KB
testcase_04 AC 22 ms
8,052 KB
testcase_05 AC 208 ms
10,908 KB
testcase_06 AC 132 ms
9,916 KB
testcase_07 AC 69 ms
9,256 KB
testcase_08 AC 133 ms
10,400 KB
testcase_09 AC 98 ms
8,968 KB
testcase_10 AC 74 ms
9,520 KB
testcase_11 AC 35 ms
9,196 KB
testcase_12 AC 119 ms
10,108 KB
testcase_13 AC 99 ms
9,132 KB
testcase_14 AC 33 ms
9,216 KB
testcase_15 AC 147 ms
10,216 KB
testcase_16 AC 94 ms
9,292 KB
testcase_17 AC 108 ms
9,520 KB
testcase_18 AC 17 ms
8,108 KB
testcase_19 AC 18 ms
8,792 KB
testcase_20 AC 16 ms
8,092 KB
testcase_21 AC 46 ms
9,060 KB
testcase_22 AC 32 ms
8,064 KB
testcase_23 AC 60 ms
9,240 KB
testcase_24 AC 79 ms
8,956 KB
testcase_25 AC 16 ms
8,016 KB
testcase_26 AC 22 ms
8,128 KB
testcase_27 AC 215 ms
11,140 KB
testcase_28 AC 142 ms
9,632 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq

INF=10**18
N,M=map(int,input().split())

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

dist=[[INF]*1002 for i in range(N)]
dist[0][0]=0

PQ=[(0,0,0)]
while PQ:
    c,v,p=heapq.heappop(PQ)
    if dist[v][p]<c:
        continue
    c+=T[v]
    p=min(p+T[v],1001)
    for e in G[v]:
        if dist[e[0]][p]>c+e[1]//p:
            dist[e[0]][p]=c+e[1]//p
            heapq.heappush(PQ,(c+e[1]//p,e[0],p))
print(min(dist[N-1]))
0