結果
問題 | No.1 道のショートカット |
ユーザー |
![]() |
提出日時 | 2016-11-15 21:23:53 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 34 ms / 5,000 ms |
コード長 | 568 bytes |
コンパイル時間 | 243 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 11,264 KB |
最終ジャッジ日時 | 2024-07-20 16:27:34 |
合計ジャッジ時間 | 2,547 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 40 |
ソースコード
from heapq import heapify, heappush, heappop n, c, v = map(int, (input() for _ in range(3))) connections = [set() for _ in range(n + 1)] for s, t, y, m in zip(*(map(int, input().split()) for _ in range(4))): connections[s].add((m, t, y)) queue = [(*con, c - con[2]) for con in connections[1] if con[2] <= c] heapify(queue) while queue: m, t, y, c = heappop(queue) if t == n: print(m) break for nm, nt, ny in connections[t]: if c < ny: continue heappush(queue, (m + nm, nt, ny, c - ny)) else: print(-1)