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;
using pdd = pair <double, double>;
#define f first
#define s second
constexpr int MAX_N = 2e5 + 5;
double calc_r(pdd last, double cord){
return (last.f - cord) * (last.f - cord)/(4 * last.s);
}
int n;
int x[MAX_N], r[MAX_N];
double ans[MAX_N];
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n;
for(int i = 0; i < n; i++){
cin >> x[i] >> r[i];
}
stack <pdd> st;
for(int i = 0; i < n; i++){
double max_r = r[i];
while(st.size() > 0){
pdd last = st.top();
double to_last = calc_r(last, x[i]);
max_r = min(max_r, to_last);
if(last.s > max_r) break;
else{
st.pop();
continue;
}
}
st.push({x[i], max_r});
ans[i] = max_r;
}
cout << fixed << setprecision(3);
for(int i = 0; i < n; i++){
cout << ans[i] << '\n';
}
}
# | 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... |