Submission #874663

# Submission time Handle Problem Language Result Execution time Memory
874663 2023-11-17T13:46:02 Z soyeb_p_jim Balloons (CEOI11_bal) C++14
30 / 100
450 ms 1864 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
#define ordered_pair_set tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update>
void solve()
{
    ll n;
    cin >> n;
    stack<pair<ld, ld>> st;
    for (int i = 0; i < n; i++)
    {
        ld pos, r;
        cin >> pos >> r;
        ld red = r;
        if (st.size() == 0)
        {
            st.push({pos, red});
            printf("%.3Lf\n", red);
        }
        else
        {
            bool ck = 0;
            ld mn = r;
            while (st.size())
            {
                ld a = st.top().second;
                ld d = pos - st.top().first;
                ld rr = (1.0 * d * d) / (4 * a);
                mn = min(mn, rr);
                if (rr < a)
                {
                    printf("%.3Lf\n", mn);
                    st.push({pos, mn});
                    ck = 1;
                    break;
                }
                else
                {
                    st.pop();
                }
                //cout << mn << " " << d << " " << a << "\n";
            }
            if (!ck)
            {
                st.push({pos, mn});
                printf("%.3Lf\n", mn);
            }
        }
    }
}
int main()
{
    //ios::sync_with_stdio(false);
    //cin.tie(nullptr);
    cout << setprecision(20);
    solve();
    return 0;
}
/*
    d^2 + (r-x)^2 = (r+x)^2
    d^2 / 4r = x
*/
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 348 KB 504th numbers differ - expected: '160.9360000000', found: '163.0000000000', error = '2.0640000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 44 ms 348 KB 653rd numbers differ - expected: '96.2810000000', found: '123.0000000000', error = '26.7190000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 121 ms 668 KB 50000 numbers
2 Incorrect 121 ms 596 KB 49903rd numbers differ - expected: '443977872.4679999948', found: '1000000000.0000000000', error = '556022127.5320000648'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 240 ms 1260 KB 14857th numbers differ - expected: '7169.6020000000', found: '7176.0000000000', error = '6.3980000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 261 ms 1364 KB 23610th numbers differ - expected: '1467.9600000000', found: '1471.0000000000', error = '3.0400000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 367 ms 1856 KB 12335th numbers differ - expected: '4957.2960000000', found: '4967.0000000000', error = '9.7040000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 450 ms 1864 KB 7553rd numbers differ - expected: '198.8980000000', found: '220.0000000000', error = '21.1020000000'
2 Halted 0 ms 0 KB -