Submission #1091428

#TimeUsernameProblemLanguageResultExecution timeMemory
1091428speedcodeBalloons (CEOI11_bal)C++17
10 / 100
371 ms4756 KiB
#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().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}});
            } 
        }
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...