結果

問題 No.1449 新プロランド
ユーザー ygd.ygd.
提出日時 2021-03-31 15:10:57
言語 PyPy3
(7.3.15)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 982 bytes
コンパイル時間 540 ms
コンパイル使用メモリ 86,748 KB
実行使用メモリ 80,912 KB
最終ジャッジ日時 2023-08-25 16:48:16
合計ジャッジ時間 6,353 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,336 KB
testcase_01 AC 121 ms
77,552 KB
testcase_02 AC 150 ms
78,460 KB
testcase_03 AC 78 ms
71,048 KB
testcase_04 AC 76 ms
71,088 KB
testcase_05 AC 266 ms
80,620 KB
testcase_06 AC 239 ms
79,956 KB
testcase_07 AC 175 ms
78,688 KB
testcase_08 AC 237 ms
80,400 KB
testcase_09 AC 209 ms
79,212 KB
testcase_10 AC 189 ms
79,624 KB
testcase_11 AC 139 ms
78,484 KB
testcase_12 AC 221 ms
80,516 KB
testcase_13 AC 224 ms
79,484 KB
testcase_14 AC 128 ms
78,224 KB
testcase_15 AC 216 ms
79,392 KB
testcase_16 AC 228 ms
80,656 KB
testcase_17 AC 228 ms
80,052 KB
testcase_18 AC 77 ms
71,308 KB
testcase_19 AC 77 ms
71,480 KB
testcase_20 AC 76 ms
70,996 KB
testcase_21 AC 161 ms
79,412 KB
testcase_22 AC 119 ms
77,852 KB
testcase_23 AC 172 ms
79,272 KB
testcase_24 AC 175 ms
78,828 KB
testcase_25 AC 75 ms
71,272 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import heapify, heappop, heappush
N,M = map(int,input().split()); INF = float("inf")
G = [[] for _ in range(N)]
for _ in range(M):
    a,b,c = map(int,input().split())
    a-=1;b-=1
    G[a].append((c,b))
    G[b].append((c,a))
T = list(map(int,input().split()))
MAX = pow(10,3) + 10
#dp[i][j]: i番目の街にいて、おにぎりを計j分食べた時の最小値
dp = [[INF]*MAX for _ in range(N)]
#dp[0][T[0]] = 0

#S:start, V: node, E: Edge, G: Graph
V = len(G)
PQ = []
s = 0
heappush(PQ,(0,s,0)) #時間:c,町:v,おにぎり:p
  
while PQ:
    c,v,p = heappop(PQ) #おにぎりを食べずに到着
    #ここで食べる
    p = p + T[v]
    if p > 1000:
        p = 1001
    c = c + T[v]
    #print(c,v,p,dp[v][p])
    if dp[v][p] < c:
        continue
    dp[v][p] = c
    for dis,u in G[v]:
        if dp[u][p] <= dis//p + dp[v][p]:
            continue
        dp[u][p] = dis//p + dp[v][p]
        heappush(PQ,(dp[u][p], u, p))

ans = min(dp[N-1])
print(ans)
0