This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
import sys
import math
towers_cnt, line_len = map(int, sys.stdin.readline().strip().split())
towers = [tuple(map(int, sys.stdin.readline().strip().split())) for _ in range(towers_cnt)]
def can_cover_whole_line(radius: float) -> bool:
curr = 0
for x, y in towers:
delta = math.sqrt(radius ** 2 - y ** 2)
a, b = x - delta, x + delta
if a <= curr: curr = max(curr, b)
return curr >= line_len
# total_dist = 0
# for x, height in towers:
# if height > radius: continue
# dist = math.sqrt(radius ** 2 - height ** 2)
# if x - dist <= total_dist <= x + dist:
# total_dist = x + dist
# return total_dist >= line_len
l, r = 0, 1.5e9
while r - l > 1e-3:
mid = (l + r) / 2
if can_cover_whole_line(radius=mid):
r = mid
else:
l = mid
print(l)
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |