結果
| 問題 |
No.2387 Yokan Factory
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-07-21 22:22:08 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 868 bytes |
| コンパイル時間 | 186 ms |
| コンパイル使用メモリ | 82,176 KB |
| 実行使用メモリ | 177,076 KB |
| 最終ジャッジ日時 | 2024-09-21 23:53:01 |
| 合計ジャッジ時間 | 25,239 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 18 WA * 17 |
ソースコード
#int(input())
#map(int, input().split())
#list(map(int, input().split()))
N, M, X = map(int, input().split())
to = [[] for i in range(N)]
for i in range(M):
u, v, a, b = map(int, input().split())
to[u-1].append((v-1, a, b))
to[v-1].append((u-1, a, b))
import heapq
min1 = 0
max1 = 10 ** 9 + 10
while max1 - min1 > 1:
h = (max1 + min1) // 2
v = [X+1] * N
q = [(0, 0)]
v[0] = 0
heapq.heapify(q)
while q:
t, x = heapq.heappop(q)
if v[x] < t:
continue
v[x] = t
for y, a, b in to[x]:
if h >= b:
continue
if v[y] < t+a or t+a > X:
continue
heapq.heappush(q, (t+a, y))
v[y] = min(v[y], t+a)
if max(v) == X+1:
max1 = h
else:
min1 = h
if min1 == 0:
print(-1)
else:
print(max1)