Submission #755523

# Submission time Handle Problem Language Result Execution time Memory
755523 2023-06-10T08:16:24 Z ZephyrOnFire Balloons (CEOI11_bal) C++17
20 / 100
255 ms 6452 KB
#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<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
        {
            while (!st.empty())
            {
                long long 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())
                    {
                        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
1 Correct 1 ms 212 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 212 KB 14th numbers differ - expected: '2.6090000000', found: '7.1410000000', error = '4.5320000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 340 KB 79th numbers differ - expected: '36.0070000000', found: '2766.0000000000', error = '2729.9930000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 25 ms 852 KB 137th numbers differ - expected: '67.1010000000', found: '3129.0000000000', error = '3061.8990000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 75 ms 1776 KB 250th numbers differ - expected: '15134.0000000000', found: '18307.0000000000', error = '3173.0000000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 143 ms 3512 KB 162nd numbers differ - expected: '7765.0000000000', found: '14571.0000000000', error = '6806.0000000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 154 ms 3940 KB 510th numbers differ - expected: '4505.0010000000', found: '13465.0000000000', error = '8959.9990000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 183 ms 5272 KB 161st numbers differ - expected: '1703.0000000000', found: '4036.0000000000', error = '2333.0000000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 255 ms 6452 KB 248th numbers differ - expected: '2694.0020000000', found: '8658.0000000000', error = '5963.9980000000'
2 Halted 0 ms 0 KB -