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 ll long long
#define pii pair<int, int>
#define pdd pair<double, double>
#define endl '\n'
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int N;
cin >> N;
auto calc_r = [](pdd &a, double x) {
return ((x - a.first)*(x - a.first))/(4*a.second);
};
stack<pdd> st;
for(int i = 0; i < N; i++) {
double x, r;
cin >> x >> r;
double max_r = r;
while(!st.empty()) {
pdd tp = st.top();
max_r = min(max_r, calc_r(tp, x));
if(max_r >= tp.second)
st.pop();
else break;
}
st.push({x, max_r});
cout << fixed << setprecision(4) << max_r << 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... |