結果

問題 No.3712 Urban Train
コンテスト
ユーザー detteiuu
提出日時 2026-09-11 21:53:40
言語 PyPy3
(7.3.23 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 497 ms / 2,000 ms
+ 219µs
コード長 1,121 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 73 ms
コンパイル使用メモリ 80,768 KB
実行使用メモリ 138,164 KB
最終ジャッジ日時 2026-09-11 21:54:01
合計ジャッジ時間 8,114 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 39
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from heapq import heappush, heappop

INF = 1<<60

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

def dijkstra(start):
    dist = [INF]*N
    dist[start] = 1
    visited = [False]*N
    que = [(0, start)]
    while que:
        d, now = heappop(que)
        if visited[now]:
            continue
        visited[now] = True
        for next, weight in G[now]:
            st = (dist[now]+A[now]-1)//A[now]*A[now]
            cost = weight
            if st//A[now]%B[now] == 0:
                cost += C[now]
            if st+cost < dist[next]:
                dist[next] = st+cost
                heappush(que, (dist[next], next))
            if st%B[now] == 0:
                st += A[now]
                if st+weight < dist[next]:
                    dist[next] = st+weight
                    heappush(que, (dist[next], next))
    return dist

print(dijkstra(0)[N-1])
0