結果
| 問題 |
No.2387 Yokan Factory
|
| コンテスト | |
| ユーザー |
cleantted
|
| 提出日時 | 2023-06-15 22:48:20 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,241 bytes |
| コンパイル時間 | 152 ms |
| コンパイル使用メモリ | 82,160 KB |
| 実行使用メモリ | 141,964 KB |
| 最終ジャッジ日時 | 2024-06-23 20:25:19 |
| 合計ジャッジ時間 | 9,152 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 14 TLE * 1 -- * 20 |
ソースコード
import heapq
def read_values(): return tuple(map(int, input().split()))
def read_index(): return tuple(map(lambda x: int(x) - 1, input().split()))
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for _ in range(N)]
def main():
N, M, X = read_values()
L = read_lists(M)
G = [[] for _ in range(N)]
for u, v, a, b in L:
u -= 1
v -= 1
G[u].append((v, a, b))
G[v].append((u, a, b))
def f(m):
S = [(0, 0)]
fixed = [False] * N
D = [X + 1] * N
D[0] = 0
while S:
c, i = heapq.heappop(S)
if i == N - 1:
return c <= X
for j, a, b in G[i]:
if m > b:
continue
c2 = c + a
if c2 > X:
continue
if D[j] <= c2:
continue
D[j] = c2
heapq.heappush(S, (c2, j))
return False
l = -1
r = 10 ** 9 + 10
while r - l > 1:
m = (l + r) // 2
if f(m):
l = m
else:
r = m
print(l)
if __name__ == "__main__":
main()
cleantted