結果
| 問題 | No.3712 Urban Train |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-09-21 18:49:17 |
| 言語 | PyPy3 (7.3.23 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 635 ms / 2,000 ms |
| + 352µs | |
| コード長 | 1,541 bytes |
| 記録 | |
| コンパイル時間 | 612 ms |
| コンパイル使用メモリ | 82,508 KB |
| 実行使用メモリ | 141,988 KB |
| 最終ジャッジ日時 | 2026-09-21 18:49:27 |
| 合計ジャッジ時間 | 9,065 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge4_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 39 |
ソースコード
# https://yukicoder.me/problems/no/3712
from collections import deque
import heapq
MAX_INT = 2 ** 65
def main():
N, M = map(int, input().split())
next_nodes = [[] for _ in range(N)]
for _ in range(M):
u, v, w = map(int ,input().split())
next_nodes[u - 1].append((v -1 , w))
next_nodes[v - 1].append((u - 1, w))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
fix = [MAX_INT] * N
seen = [MAX_INT] * N
queue = []
heapq.heappush(queue, (0, 0))
seen[0] = 0
while len(queue) >0:
cost, v = heapq.heappop(queue)
if fix[v] < MAX_INT:
continue
fix[v] = cost
for u, w in next_nodes[v]:
if fix[u] < MAX_INT:
continue
# コスト計算
d = cost % A[v]
if d > 0 or cost == 0:
next_time = ((cost // A[v]) + 1) * A[v]
else:
next_time = cost
next_time_list = [next_time]
if next_time % (A[v] * B[v]) == 0:
next_time_list.append(next_time + A[v])
for n in next_time_list:
if n % (A[v] * B[v]) == 0:
new_cost = n + w + C[v]
else:
new_cost = n + w
if seen[u] > new_cost:
seen[u] = new_cost
heapq.heappush(queue, (new_cost, u))
print(fix[-1])
if __name__ == "__main__":
main()