#include "bits/stdc++.h"
using namespace std;
struct Balloon {
long double r;
long double x;
int idx;
};
int main() {
int n;
cin >> n;
vector<Balloon> balloons(n);
for (int i = 0; i < n; i++) {
cin >> balloons[i].x;
cin >> balloons[i].r;
balloons[i].idx = i;
}
stack<Balloon> s;
s.push(balloons[0]);
vector<long double> final_r(n);
for (int i = 1; i < n; i++) {
while (!s.empty() && s.top().r < (balloons[i].x - s.top().x) * (balloons[i].x - s.top().x) / (4.0 * s.top().r)) {
final_r[s.top().idx] = s.top().r;
s.pop();
}
if (s.empty()) {
s.push(balloons[i]);
} else {
long double new_r = (balloons[i].x - s.top().x) * (balloons[i].x - s.top().x) / (4.0 * s.top().r);
s.push({min(new_r, balloons[i].r), balloons[i].x, balloons[i].idx});
}
}
while (!s.empty()) {
final_r[s.top().idx] = s.top().r;
s.pop();
}
for (int i = 0; i < n; i++) {
cout << fixed << setprecision(3) << final_r[i] << endl;
}
}
| # | 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... |