結果

問題 No.3712 Urban Train
コンテスト
ユーザー AP25
提出日時 2026-09-11 22:32:26
言語 PyPy3
(7.3.23 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 481 ms / 2,000 ms
+ 816µs
コード長 843 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 71 ms
コンパイル使用メモリ 80,640 KB
実行使用メモリ 139,188 KB
最終ジャッジ日時 2026-09-11 22:32:34
合計ジャッジ時間 7,153 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 39
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from heapq import *
inf = float("inf")

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

dist = [inf] * N
dist[0] = 0
hq = []
heappush(hq,(dist[0],0))

while hq:
    d, x = heappop(hq)
    if dist[x] != d:
        continue

    if d == 0:
        k = 1
    else:
        k = (d + A[x] - 1) // A[x]

    ad = A[x] * k - d
    if k % B[x] == 0:
        ad = min(ad + C[x], A[x] * (k+1) -d)


    for nx, c in G[x]:
        nd = dist[x] + ad + c
        if dist[nx] > nd:
            dist[nx] = nd
            heappush(hq,(dist[nx],nx))


print(dist[N-1])
0