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 <vector>
#include <iostream>
#include <stack>
#include <iomanip>
using namespace std;
struct ustruct
{
int x;
long double r;
};
signed main()
{
int n;
cin >> n;
int x[n], maxr[n];
for (int i = 0; i < n; i++)
{
cin >> x[i] >> maxr[i];
}
stack<ustruct> st;
vector<double> ans(n, 0.0);
for (int i = 0; i < n; i++)
{
if (st.empty())
{
ustruct a;
a.x = x[i];
a.r = double(maxr[i]);
st.push(a);
ans[i] = a.r;
}
else
{
while (!st.empty())
{
int prevx = st.top().x;
long double prevr = st.top().r;
long double curr;
long double wantr = ((x[i] - prevx + 0.0) * (x[i] - prevx + 0.0)) / (4 * prevr + 0.0);
if (wantr >= maxr[i])
{
curr = maxr[i];
}
else
{
curr = wantr;
}
if (curr >= prevr)
{
st.pop();
if (st.empty())
{
ustruct a;
a.x = x[i];
a.r = double(maxr[i]);
st.push(a);
// st.push({x[i], (double)maxr[i]});
ans[i] = st.top().r;
break;
}
}
else
{
//
ustruct a;
a.x = x[i];
a.r = double(curr);
st.push(a);
// st.push({x[i], curr});
ans[i] = st.top().r;
break;
}
}
}
}
// cout << ans.size();
cout<<fixed<< setprecision(3);
for (auto i : ans)
{
cout << i << " ";
// cout << 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... |