This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
# https://oj.uz/problem/view/BOI12_mobile
EPS = 0.00001
n, l = map(int, input().split())
def dist(c1, c2):
return ((c1[0] - c2[0]) ** 2 + (c1[1] - c2[1]) ** 2) ** 0.5
coordinates = []
for _ in range(n):
x, y = map(int, input().split())
coordinates.append((x, y))
def merge(intervals):
new_intervals = []
for start, end in sorted(intervals):
if not new_intervals or new_intervals[-1][1] < start:
new_intervals.append([start, end])
else:
new_intervals[-1][1] = max(new_intervals[-1][1], end)
return new_intervals
def bs(lo, hi):
def ok(radius):
intervals = []
for x1, y1 in coordinates:
term = (radius ** 2) - (y1 ** 2)
if term >= 0:
term_sqrt = term ** 0.5
intervals.append((x1 - term_sqrt, x1 + term_sqrt))
intervals = merge([(0, 0)] + intervals + [(l, l)])
for i in range(len(intervals) - 1):
midpt = (intervals[i][1] + intervals[i + 1][0]) / 2
if 0 <= midpt <= l:
return True
return False
while lo + EPS < hi:
mid = (lo + hi) / 2
if not ok(mid):
hi = mid
else:
lo = mid
return lo
print(bs(0, 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... |