結果

問題 No.1449 新プロランド
ユーザー 👑 KazunKazun
提出日時 2021-05-19 13:21:07
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 196 ms / 2,000 ms
コード長 663 bytes
コンパイル時間 299 ms
コンパイル使用メモリ 87,292 KB
実行使用メモリ 79,640 KB
最終ジャッジ日時 2023-08-25 16:53:24
合計ジャッジ時間 4,184 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,652 KB
testcase_01 AC 75 ms
71,336 KB
testcase_02 AC 75 ms
71,168 KB
testcase_03 AC 77 ms
71,504 KB
testcase_04 AC 78 ms
71,668 KB
testcase_05 AC 125 ms
79,080 KB
testcase_06 AC 81 ms
75,728 KB
testcase_07 AC 78 ms
71,436 KB
testcase_08 AC 94 ms
76,540 KB
testcase_09 AC 79 ms
71,436 KB
testcase_10 AC 82 ms
75,364 KB
testcase_11 AC 80 ms
75,424 KB
testcase_12 AC 134 ms
78,296 KB
testcase_13 AC 78 ms
71,460 KB
testcase_14 AC 79 ms
71,440 KB
testcase_15 AC 81 ms
75,508 KB
testcase_16 AC 80 ms
71,444 KB
testcase_17 AC 96 ms
76,816 KB
testcase_18 AC 78 ms
71,716 KB
testcase_19 AC 82 ms
75,400 KB
testcase_20 AC 78 ms
71,316 KB
testcase_21 AC 80 ms
71,600 KB
testcase_22 AC 80 ms
71,300 KB
testcase_23 AC 81 ms
75,528 KB
testcase_24 AC 79 ms
71,468 KB
testcase_25 AC 78 ms
71,432 KB
testcase_26 AC 79 ms
71,168 KB
testcase_27 AC 196 ms
79,640 KB
testcase_28 AC 102 ms
77,028 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import heapify,heappop,heappush

N,M=map(int,input().split())
E=[[] for _ in range(N)]
C_max=0

for _ in range(M):
    a,b,c=map(int,input().split())
    a-=1; b-=1;

    E[a].append((b,c))
    E[b].append((a,c))

    C_max=max(C_max,c)

T=list(map(int,input().split()))
T_max=max(T)

inf=float("inf")
D=[[inf]*(C_max+2) for _ in range(N)]

D[0][T[0]]=T[0]
Q=[(T[0],0,T[0])]
heapify(Q)

while Q:
    d,x,t=heappop(Q)

    if x==N-1:
        break

    if D[x][t]<d:
        continue

    for b,c in E[x]:
        k=d+c//t+T[b]
        u=min(C_max+1,t+T[b])
        if k<D[b][u]:
            D[b][u]=k
            heappush(Q,(k,b,u))

print(min(D[-1]))
0