結果

問題 No.1449 新プロランド
ユーザー roarisroaris
提出日時 2021-04-01 02:48:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 723 ms / 2,000 ms
コード長 816 bytes
コンパイル時間 281 ms
コンパイル使用メモリ 86,960 KB
実行使用メモリ 89,324 KB
最終ジャッジ日時 2023-08-25 16:51:25
合計ジャッジ時間 9,943 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
76,388 KB
testcase_01 AC 140 ms
78,100 KB
testcase_02 AC 192 ms
78,488 KB
testcase_03 AC 125 ms
77,560 KB
testcase_04 AC 148 ms
78,080 KB
testcase_05 AC 723 ms
89,324 KB
testcase_06 AC 464 ms
83,792 KB
testcase_07 AC 315 ms
83,396 KB
testcase_08 AC 529 ms
87,696 KB
testcase_09 AC 299 ms
80,056 KB
testcase_10 AC 307 ms
84,664 KB
testcase_11 AC 178 ms
84,624 KB
testcase_12 AC 505 ms
86,276 KB
testcase_13 AC 324 ms
81,128 KB
testcase_14 AC 180 ms
85,088 KB
testcase_15 AC 543 ms
85,144 KB
testcase_16 AC 380 ms
82,020 KB
testcase_17 AC 406 ms
83,112 KB
testcase_18 AC 79 ms
75,140 KB
testcase_19 AC 80 ms
75,160 KB
testcase_20 AC 79 ms
75,156 KB
testcase_21 AC 241 ms
83,528 KB
testcase_22 AC 174 ms
78,460 KB
testcase_23 AC 272 ms
85,408 KB
testcase_24 AC 254 ms
79,328 KB
testcase_25 AC 201 ms
79,088 KB
testcase_26 AC 102 ms
77,392 KB
testcase_27 AC 710 ms
89,284 KB
testcase_28 AC 392 ms
81,412 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
from heapq import *

def dijkstra():
    dist = [[10**18]*(10**4+10) for _ in range(N)]
    dist[0][T[0]] = T[0]
    pq = [(T[0], T[0])]
    
    while pq:
        d, vt = heappop(pq)
        v, t = divmod(vt, 10**6)
        
        if dist[v][t]<d:
            continue
        
        for nv, w in G[v]:
            if t+T[nv]<10**4+10 and dist[nv][t+T[nv]]>dist[v][t]+w//t+T[nv]:
                dist[nv][t+T[nv]] = dist[v][t]+w//t+T[nv]
                heappush(pq, (dist[nv][t+T[nv]], nv*10**6+t+T[nv]))
    
    return min(dist[-1])-T[-1]

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

for _ in range(M):
    A, B, C = map(int, input().split())
    G[A-1].append((B-1, C))
    G[B-1].append((A-1, C))

T = list(map(int, input().split()))
print(dijkstra())
0