#include <bits/stdc++.h>
using namespace std;
const long double eps = 1e-9;
void sol() {
int n; cin >> n;
vector<pair<double, double>> v(n);
for(int i = 0; i < n; i++) cin >> v[i].first >> v[i].second;
vector<double> ans(n);
auto radius = [&](int curr, pair<double, double> prev) -> double {
double r = (v[curr].first - prev.first) * ((v[curr].first - prev.first)) / (4 * prev.second);
return r;
};
stack<pair<double, double>> mono;
for(int i = 0; i < n; i++){
double R = v[i].second;
while(!mono.empty()){
pair<double, double> t = mono.top();
double r = radius(i, t);
R = min(R, r);
if(R >= t.second){
mono.pop();
continue;
}
else break;
}
mono.push(make_pair(v[i].first, R));
ans[i] = R;
}
for(auto el : ans){
cout << fixed << setprecision(6) << el << ' ';
}
}
int main()
{
//freopen("BALLOONS.INP","r",stdin);
//freopen("BALLOONS.OUT","w",stdout);
sol();
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... |