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 calc(pair<double, double> p, double x) {
return (p.first - x) * (p.first - x) / (4 * p.second);
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
vector<double> res(n);
stack<pair<double, double>> st;
for(int i=0; i<n; i++) {
double x, r;
cin >> x >> r;
double max_r = r;
while(!st.empty()) {
pair<double, double> last = st.top();
double last_r = calc(last, x);
max_r = min(max_r, last_r);
if(max_r >= last.second) {
st.pop();
} else break;
}
res[i] = max_r;
st.push({x, r});
}
cout << fixed << setprecision(3);
for(auto &x: res)
cout << x << ' ';
}
# | 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... |