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
{
long long x;
long double r;
};
signed main()
{
long long n;
cin >> n;
long long x[n], maxr[n];
for (long long i = 0; i < n; i++)
{
cin >> x[i] >> maxr[i];
}
stack<ustruct> st;
// cout<<__cplusplus<<endl;
vector<long double> ans(n, 0.0);
for (long long i = 0; i < n; i++)
{
if (st.empty())
{
st.push({x[i],(long double)maxr[i]});
ans[i] = maxr[i];
}
else
{
long double curr = 1e10;
while (!st.empty())
{
long long prevx = st.top().x;
long double prevr = st.top().r;
long double wantr = ((x[i] - prevx + 0.0) * (x[i] - prevx + 0.0)) / (4 * prevr + 0.0);
if (wantr >= maxr[i])
{
curr = min((long double)maxr[i], curr);
}
else
{
curr = min(wantr, curr);
}
if (curr >= prevr)
{
st.pop();
if (st.empty())
{
st.push({x[i], (long double)curr});
// st.push({x[i], (double)maxr[i]});
ans[i] = st.top().r;
break;
}
}
else
{
//
st.push({x[i], (long double)(curr)});
ans[i] = st.top().r;
break;
}
}
}
}
cout << fixed << setprecision(3);
for (auto i : ans)
{
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... |