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;
typedef long long ll;
int main()
{
ios::sync_with_stdio(false);
int n;
cin >> n;
stack<pair<double, pair<double, double>>> hi; // position, radius
while (n--)
{
double x, r;
cin >> x >> r;
double radius = r;
while (hi.size() && x > hi.top().first)
{
hi.pop();
}
if (!hi.size())
{
hi.push({1000000002, {radius, x}});
cout << fixed << setprecision(3) << radius << '\n';
}
else
{
auto u = hi.top();
radius = min(r, pow(x - u.second.second, 2) / 4.0 / u.second.first);
cout << fixed << setprecision(3) << radius << '\n';
while (hi.size())
{
if (radius >= hi.top().second.first)
{
hi.pop();
continue;
}
double d = sqrt(radius / hi.top().second.first);
double g = (x - d * hi.top().second.second) / (1 - d);
if (g >= hi.top().first)
{
hi.pop();
}
else
break;
}
if (hi.size())
{
double d = sqrt(radius / hi.top().second.first);
double g = (x - d * hi.top().second.second) / (1 - d);
hi.push({g, {radius, x}});
}
else
{
hi.push({1000000002, {radius, x}});
}
}
cout << "";
}
}
# | 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... |