Submission #1091428

# Submission time Handle Problem Language Result Execution time Memory
1091428 2024-09-20T20:28:39 Z speedcode Balloons (CEOI11_bal) C++17
10 / 100
371 ms 4756 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().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 time Memory Grader output
1 Incorrect 0 ms 600 KB 4th numbers differ - expected: '1.8420000000', found: '87.0000000000', error = '85.1580000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB 15th numbers differ - expected: '0.8630000000', found: '6.6780000000', error = '5.8150000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 348 KB 80th numbers differ - expected: '33.0560000000', found: '140.0000000000', error = '106.9440000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 39 ms 828 KB 138th numbers differ - expected: '56.3670000000', found: '256.0650000000', error = '199.6980000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 98 ms 1500 KB 251st numbers differ - expected: '15123.0020000000', found: '18307.0000000000', error = '3183.9980000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 211 ms 2952 KB 163rd numbers differ - expected: '7762.0000000000', found: '14571.0000000000', error = '6809.0000000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 222 ms 3148 KB 511th numbers differ - expected: '4494.0050000000', found: '13465.0000000000', error = '8970.9950000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 302 ms 3924 KB 162nd numbers differ - expected: '1700.0010000000', found: '4036.0000000000', error = '2335.9990000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 371 ms 4756 KB 249th numbers differ - expected: '2683.0090000000', found: '8658.0000000000', error = '5974.9910000000'
2 Halted 0 ms 0 KB -