#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define db double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define pb push_back
#define all(x) begin(x), end(x)
#define allr(x) rbegin(x), rend(x)
#define szx(x) ((int)(x).size())
#define FOR(i, a, b) for (int i = a, _b = (b); i <= _b; ++i)
#define ROF(i, a, b) for (int i = a, _b = (b); i >= _b; --i)
#define REP(i, n) for (int i = 0, _n = (n); i < _n; ++i)
#define endl '\n'
#define inf 1000000007
#define mod 1000000007
// #define mod 998244353
using namespace std;
using namespace __gnu_pbds;
void setIO() {
ios::sync_with_stdio(0);
cin.tie(0);
}
void openFile(string filename = "") {
if (!filename.empty())
if (ifstream(filename + ".in")) {
freopen((filename + ".in").c_str(), "r", stdin);
freopen((filename + ".out").c_str(), "w", stdout);
}
}
ll binpow(ll a, ll b, int m = mod) {
ll res = 1;
a %= m;
while (b) {
if (b & 1) res = (a * res) % m;
a = (a * a) % m;
b >>= 1;
}
return res;
}
const int FMAX = 2e5 + 5;
ll fact[FMAX], invf[FMAX];
void process() {
fact[1] = fact[0] = invf[1] = invf[0] = 1;
FOR(i, 2, FMAX - 1) fact[i] = (fact[i - 1] * i) % mod;
invf[FMAX - 1] = binpow(fact[FMAX - 1], mod - 2, mod);
ROF(i, FMAX - 1, 1) invf[i - 1] = invf[i] * i % mod;
}
ll comb(int a, int b) {
b = min(b, a - b);
if (a < 0 || b < 0) return 0;
return fact[a] * (invf[b] * invf[a - b] % mod) % mod;
}
const int PMAX = 1e6 + 5;
bool prime[PMAX + 1];
void sieve() {
fill(prime, prime + PMAX + 1, 1);
prime[0] = prime[1] = 0;
for (int i = 2; i * i <= PMAX; i++) {
if (prime[i] == 0) continue;
prime[i] = 1;
for (ll j = i * i; j <= PMAX; j += i) prime[j] = 0;
}
}
struct DSU {
vector<int> comp;
ll ans = 0;
DSU(int n) { comp.assign(n + 5, -1); }
int find(int v) { return comp[v] < 0 ? v : comp[v] = find(comp[v]); }
void unite(int u, int v) {
u = find(u), v = find(v);
if (u == v) return;
if (comp[u] > comp[v]) swap(u, v);
comp[u] += comp[v];
comp[v] = u;
}
int getsz(int v) { return -comp[find(v)]; }
bool same(int u, int v) { return find(u) == find(v); }
};
const int MAX = 2e5 + 5;
int n;
pair<int, double> a[MAX];
db calc(int x, pair<int, double> b) { return (x - b.fi) * (x - b.fi) / (4 * b.se); }
void solve() {
vector<db> ans(n);
stack<pair<int, db>> st;
REP(i, n) {
db r = a[i].se;
while (szx(st) >= 2) {
pair<int, db> x = st.top();
st.pop();
pair<int, db> y = st.top();
st.pop();
db r1 = calc(a[i].fi, x), r2 = calc(a[i].fi, y);
r = min({r, r1, r2});
if (r1 > r2)
st.push(y);
else {
st.push(y), st.push(x);
break;
}
}
while (!st.empty() && r >= st.top().se) st.pop();
ans[i] = r;
st.push({a[i].fi, r});
}
REP(i, n) cout << fixed << setprecision(3) << ans[i] << endl;
}
void input() {
cin >> n;
REP(i, n) cin >> a[i].fi >> a[i].se;
}
void preprocess() {}
int main() {
setIO();
openFile("main");
int t = 1;
// cin >> t;
preprocess();
while (t--) {
input();
solve();
}
}
Compilation message (stderr)
bal.cpp: In function 'void openFile(std::string)':
bal.cpp:32:20: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
32 | freopen((filename + ".in").c_str(), "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bal.cpp:33:20: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
33 | freopen((filename + ".out").c_str(), "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| # | 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... |