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;
#define pr pair<double, int>
#define ll long long
#define pb push_back
#define f first
#define s second
int main(){
int n; cin>>n;
vector<double> x(n), r(n);
for (int i=0;i<n; i++) cin>>x[i]>>r[i];
stack<pr> st;
double ans[n];
for (int i=0; i<n; i++){
double br=r[i];
while(!st.empty() ){
br=min(br, (x[i]-st.top().s)*(x[i]-st.top().s)/(4*st.top().f));
if(br>st.top().f){
st.pop();
}
else{
break;
}
}
st.push({br, x[i]});
ans[i]=br;
}
cout << fixed << setprecision(3);
for (int i=0; i<n; i++) cout<<ans[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... |