#include <bits/stdc++.h>
using namespace std;
using db = double;
using pdd = pair<db, db>;
deque<pdd> stk;
int n;
db x, r;
db quad(db a, db b, db c) {
return (-b + sqrt(b*b-4*a*c)) / 2 / a;
}
db getx(pdd a, pdd b) {
return quad(1/a.second/4 - 1/b.second/4, b.first/2/b.second - a.first/2/a.second, a.first*a.first/4/a.second - b.first*b.first/4/b.second);
}
db getrad(pdd xr, db xtwo) {
return (xr.first - xtwo) * (xr.first - xtwo) / 4 / xr.second;
}
int main() {
cin.tie(0) -> sync_with_stdio(0);
cin >> n;
cout << fixed << setprecision(3);
while(n--) {
cin >> x >> r;
//cout << stk.size() << '\n';
while(stk.size()>1 && getrad(stk[stk.size()-2], x) <= getrad(stk[stk.size()-1], x)) {
stk.pop_back();
}
pdd topush = {x, (stk.empty() ? r : min(r, getrad(stk.back(), x)))};
while(!stk.empty() && stk.back().second <= topush.second) stk.pop_back();
while(stk.size() > 1 && getx(stk[stk.size()-2], topush) <= getx(stk[stk.size()-1], topush)) stk.pop_back();
stk.emplace_back(topush);
cout << topush.second << '\n';
}
}
# | 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... |