This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// aww geometria !! :)
#include <bits/stdc++.h>
typedef long double ld;
using namespace std;
ld maxr(ld x1, ld r1, ld x2)
{
ld x = r1, z = x2 - x1;
return (z * z) / (4. * x);
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout << fixed << setprecision(3);
int n;
cin >> n;
vector<ld> x(n), r(n);
vector<int> st;
for (int i = 0; i < n; i++)
{
cin >> x[i] >> r[i];
while (st.size() > 1 && maxr(x[st.back()], r[st.back()], x[i]) > maxr(x[st[st.size() - 2]], r[st[st.size() - 2]], x[i]))
st.pop_back();
while (!st.empty() && r[st.back()] < r[i])
r[i] = min(r[i], maxr(x[st.back()], r[st.back()], x[i])), st.pop_back();
if (!st.empty()) r[i] = min(r[i], maxr(x[st.back()], r[st.back()], x[i]));
st.push_back(i);
}
for (int i = 0; i < n; i++) cout << r[i] << "\n";
return 0;
}
# | 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... |