Submission #1091430

# Submission time Handle Problem Language Result Execution time Memory
1091430 2024-09-20T20:34:25 Z speedcode Balloons (CEOI11_bal) C++17
100 / 100
378 ms 5460 KB
#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
1 Correct 0 ms 348 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 4 ms 348 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 38 ms 740 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 107 ms 1360 KB 50000 numbers
2 Correct 93 ms 1620 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 194 ms 2644 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 230 ms 3144 KB 115362 numbers
2 Correct 225 ms 3356 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 324 ms 3920 KB 154271 numbers
2 Correct 368 ms 5460 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 378 ms 4712 KB 200000 numbers
2 Correct 378 ms 5456 KB 199945 numbers