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>
#define f first
#define s second
#define N 200005
#define int long long
using namespace std;
double pos[N],rad[N];
stack<pair<double,double>> st;
double inflate(double x,double r) {
while (!st.empty()) {
double x1 = st.top().f, r1 = st.top().s;
r = min(r, ((x1 - x) * (x1 - x)) / (4 * r1));
if (r >= r1)
st.pop();
else
break;
}
st.push({x, r});
return r;
}
signed main() {
int n;
cin >> n;
for (int i = 0; i < n; i++)
cin >> pos[i] >> rad[i];
for (int i = 0; i < n; i++)
cout << fixed<<setprecision(3)<<inflate(pos[i], rad[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... |