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;
const int nx=2e5+5;
double n, x[nx], mx[nx], dp[nx];
set<pair<double, long long>> ms;
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
cin>>n;
for (int i=1; i<=n; i++) cin>>x[i]>>mx[i];
for (int i=1; i<=n; i++)
{
if (ms.empty()) dp[i]=mx[i], ms.insert({DBL_MAX, i});
else
{
auto itr=ms.lower_bound({x[i], LLONG_MAX});
dp[i]=min(double(mx[i]), ((x[i]-x[itr->second])*(x[i]-x[itr->second]))/(4*dp[itr->second]));
while (dp[ms.begin()->second]<=dp[i]&&!ms.empty()) ms.erase(ms.begin());
if (ms.empty()) ms.insert({DBL_MAX, i});
else
{
long long l=ms.begin()->second;
double a=dp[i]-dp[l], b=-2*(dp[i]*x[l]-dp[l]*x[i]), c=dp[i]*x[l]*x[l]-dp[l]*x[i]*x[i];
double tmp=max((-b+sqrt(b*b-4*a*c))/(2*a), (-b-sqrt(b*b-4*a*c))/(2*a));
ms.insert({tmp, i});
while (!ms.empty()&&ms.begin()->second!=i) ms.erase(ms.begin());
}
}
//cout<<i<<'\n';
//for (auto [x, y]:ms) cout<<x<<' '<<y<<'\n';
}
for (int i=1; i<=n; i++) printf("%.3f\n", dp[i]);
}
# | 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... |