#include <bits/stdc++.h>
#ifdef LOCAL
#include "debug/debug.hpp"
#else
#define print(...)
#endif
using ll = long long;
using ld = long double;
using ull = unsigned long long;
#define str string
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define ent cout << "\n";
#define sz(v) ll(v.size())
using namespace std;
const long long MOD = 1e9 + 7, inf = 1e18;
ld esp = 1e-7;
ld get_pos(ld x1, ld y1, ld x2, ld y2) {
// print()
ld s = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
return s;
}
void solve() {
ll n;
cin >> n;
ld x[n + 17], r[n + 17];
vector<pair<ld, ld>> pos;
cout << fixed << setprecision(7);
for (ll i = 1; i <= n; i++) {
cin >> x[i] >> r[i];
if (sz(pos) == 0) {
cout << r[i] << '\n';
pos.push_back({x[i], r[i]});
} else {
ld lf = 0, rg = r[i] + esp;
// print(pos);
// print(get_pos(0, 9, 8, 0.5));
// print(get_pos(0, 9, 13, 3.5), 3.5 + 9);
while (rg - lf > esp) {
ld mid = (lf + rg) / 2.0;
// print(mid);
// print(lf + esp, rg);
// cout << (rg - lf) << ' ' << esp << '\n';
ll ok = 1;
for (auto c : pos) {
if (get_pos(c.fi, c.se, x[i], mid) - (mid + c.se) < esp) {
ok = 0;
}
}
// print(mid, ok);
if (ok) {
lf = mid;
} else {
rg = mid;
}
}
cout << lf << '\n';
if (pos[0].fi + pos[0].se - x[i] + lf < esp) {
pos.pop_back();
pos.push_back({x[i], lf});
}
}
}
}
int32_t main() {
#ifdef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
#endif
ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
ll ttest = 1;
// cin >> ttest;
for (ll test_number = 1; test_number <= ttest; test_number++) {
solve();
}
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... |