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 long long long
using namespace std;
double calcr(pair<double,double> pr, double xc)
{
return (pr.first-xc)*(pr.first-xc)/(4*pr.second);
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin>>n;
stack<pair<double,double>> st;
vector<double> ans(n);
for(int i=0; i<n; i++)
{
double x,r;
cin>>x>>r;
double max_r=r;
while(!st.empty())
{
pair<double,double> prev=st.top();
double new_r=calcr(prev,x);
max_r=min(new_r,max_r);
if(max_r>=prev.second)
{
st.pop();
continue;
}
else
{
break;
}
}
st.push({x, max_r});
ans[i]=max_r;
}
cout<<fixed<<setprecision(3);
for (double &r : ans) { cout << r << "\n"; }
return 0;
}
# | 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... |