This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
from collections import deque
n = int(input())
x, r = [], []
def getrj(ri, xi, xj):
return (xj-xi)/(4*ri)*(xj-xi)
assert (getrj(9, 0, 13)) - 4.694 <= 0.001
for i in range(n):
xi, ri = map(int, input().split())
x.append(xi)
r.append(ri)
st = deque()
r2 = []
for bal in range(n):
mn = r[bal]
while st:
tp = st.pop()
mn = min(mn, getrj(r2[tp], x[tp], x[bal]))
if mn >= r2[tp]:
continue
else:
st.append(tp)
break
st.append(bal)
print(mn)
r2.append(mn)
# | 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... |