結果
問題 | No.2387 Yokan Factory |
ユーザー |
|
提出日時 | 2023-07-21 21:49:26 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 2,283 ms / 5,000 ms |
コード長 | 792 bytes |
コンパイル時間 | 189 ms |
コンパイル使用メモリ | 81,920 KB |
実行使用メモリ | 181,736 KB |
最終ジャッジ日時 | 2024-09-21 23:16:57 |
合計ジャッジ時間 | 19,346 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 35 |
ソースコード
from collections import defaultdictfrom heapq import heappop, heappushn, m, x = map(int, input().split())G = defaultdict(list)for _ in range(m):u, v, a, b = map(int, input().split())u -= 1v -= 1G[u].append((v, a, b))G[v].append((u, a, b))left, right = -1, 10**9while right - left > 1:mid = (left + right) // 2DP = [x + 1 for _ in range(n)]DP[0] = 0H = [(0, 0)]while H:cc, cp = heappop(H)if cc > DP[cp]:continuefor np, a, b in G[cp]:if b < mid:continueif cc + a >= DP[np]:continueDP[np] = cc + aheappush(H, (cc + a, np))if DP[n - 1] == x + 1:right = midelse:left = midprint(left)