結果

問題 No.1449 新プロランド
ユーザー shiomusubi496shiomusubi496
提出日時 2021-03-30 23:59:10
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 216 ms / 2,000 ms
コード長 793 bytes
コンパイル時間 106 ms
コンパイル使用メモリ 10,784 KB
実行使用メモリ 11,148 KB
最終ジャッジ日時 2023-08-25 16:44:50
合計ジャッジ時間 3,424 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
8,132 KB
testcase_01 AC 27 ms
8,000 KB
testcase_02 AC 38 ms
8,044 KB
testcase_03 AC 18 ms
8,008 KB
testcase_04 AC 22 ms
8,092 KB
testcase_05 AC 209 ms
10,872 KB
testcase_06 AC 130 ms
9,912 KB
testcase_07 AC 67 ms
9,368 KB
testcase_08 AC 129 ms
10,444 KB
testcase_09 AC 95 ms
9,136 KB
testcase_10 AC 74 ms
9,680 KB
testcase_11 AC 34 ms
9,164 KB
testcase_12 AC 118 ms
10,184 KB
testcase_13 AC 101 ms
9,276 KB
testcase_14 AC 33 ms
9,104 KB
testcase_15 AC 143 ms
10,348 KB
testcase_16 AC 91 ms
9,344 KB
testcase_17 AC 108 ms
9,636 KB
testcase_18 AC 17 ms
8,012 KB
testcase_19 AC 18 ms
8,712 KB
testcase_20 AC 17 ms
8,012 KB
testcase_21 AC 44 ms
8,980 KB
testcase_22 AC 32 ms
8,100 KB
testcase_23 AC 61 ms
9,344 KB
testcase_24 AC 80 ms
8,772 KB
testcase_25 AC 18 ms
8,092 KB
testcase_26 AC 22 ms
8,008 KB
testcase_27 AC 216 ms
11,148 KB
testcase_28 AC 142 ms
9,644 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq

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

assert 2<=N<=100
assert 1<=M<=100

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

assert len(T)==N

for i in range(len(T)):
    if i==0:
        assert T[i]!=0
    elif i==N-1:
        assert T[i]==0
    else:
        assert 0<=T[i]<=1000

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