結果

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

ソースコード

diff #
raw source code

n, m = list(map(int, input().split()))
node = [[] for _ in range(n)]
for _ in range(m):
    u, v, w = list(map(lambda x: int(x)-1, input().split()))
    node[u].append((v, w+1))
    node[v].append((u, w+1))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
inf = 1<<60
D = [inf] * n
D[0] = 1
from heapq import heappush, heappop
hq = []
heappush(hq, (1, 0))
while hq:
    c, u = heappop(hq)
    if D[u] < c: continue
    for v, w in node[u]:
        k = (c+A[u]-1)//A[u]
        if k % B[u] == 0:
            nc = min(k*A[u]+w+C[u], k*A[u]+w+A[u])
        else:
            nc = k*A[u]+w
        if D[v] > nc:
            D[v] = nc
            heappush(hq, (nc, v))

print(D[-1])
0