This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
double maxRadius(int x1, int x2, double r1) {
/**
* (x2 - x1)^2 + (r2 - r1)^2 = (r2 + r1)^2
* (x2 - x1)^2 = 4 r1 r2
*/
return 1LL * (x2 - x1) * (x2 - x1) / (4 * r1);
}
int main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
int n; cin >> n;
vector<pair<int, double>> a(n); // [x, maxRadius]
for (auto &[x, r]: a) cin >> x >> r;
stack<pair<int, double>> st; // [position, radius]
cout << fixed << setprecision(3);
for (int i = 0; i < n; i++) {
auto [x2, maxR2] = a[i];
double r2 = maxR2;
while (not st.empty()) {
auto [x1, r1] = st.top();
r2 = min(r2, maxRadius(x1, x2, r1));
if (r2 < r1) break;
st.pop();
}
st.emplace(x2, r2);
cout << r2 << '\n';
}
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... |