Submission #1094828

# Submission time Handle Problem Language Result Execution time Memory
1094828 2024-09-30T16:04:40 Z Kodik Balloons (CEOI11_bal) C++17
0 / 100
394 ms 7252 KB
#include <bits/stdc++.h>
using namespace std;
#define ss second
#define ff first
typedef long long ll;
typedef long double ld;
#define int ll




bool check(ld nr, ld lr, ld nx, ld lx){
    ld radius = abs(nr-lr);
    ld distance = abs(nx-lx);
    ld pyt = lr + nr;
    return (radius*radius + distance*distance - pyt*pyt ) >= ld(1e-7);
}


signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vector<ld> answer(n);
    stack<pair<ld,ld>> st;
    for(int i = 0; i < n; ++i){
        ld cor, mr; 
        cin >> cor >> mr;
        if(st.empty()){
            answer[i] = mr;
            st.push({mr,cor});
        }else{
            while(true){
                auto &[lr, lx] = st.top();
                ld l = 0, r = mr;
                while(r-l>1e-7){
                    ld mid = l + (r-l)/2;
                    if(check(mid, lr, cor, lx)){
                        l = mid;
                    }else{
                        r = mid;
                    }

                }
                mr = l;
                if(l>lr){
                    st.pop();
                    mr = l;
                    if(st.empty()){
                        answer[i] = mr;
                        st.push({mr,cor});
                        break;
                    }
                }else{
                    st.push({mr,cor});
                    answer[i] = mr;
                    break;
                }
            }
        }
    }
    cout.precision(4); 
    for(int i = 0; i < n; ++i){
        cout << answer[i] << '\n';
    }
    return 0;   
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 5th numbers differ - expected: '17.1630000000', found: '17.1600000000', error = '0.0030000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB 1st numbers differ - expected: '247294217.0000000000', found: '247300000.0000000000', error = '5783.0000000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB 314th numbers differ - expected: '10.1250000000', found: '10.1300000000', error = '0.0050000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 348 KB 2nd numbers differ - expected: '122.0020000000', found: '122.0000000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 40 ms 1108 KB 50th numbers differ - expected: '159.0020000000', found: '159.0000000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 102 ms 2612 KB 1st numbers differ - expected: '15399.0000000000', found: '15400.0000000000', error = '1.0000000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 214 ms 4300 KB 285th numbers differ - expected: '7629.0020000000', found: '7629.0000000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 251 ms 4756 KB 511th numbers differ - expected: '4494.0050000000', found: '4494.0000000000', error = '0.0050000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 334 ms 5972 KB 164th numbers differ - expected: '1698.0020000000', found: '1698.0000000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 394 ms 7252 KB 248th numbers differ - expected: '2694.0020000000', found: '2694.0000000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -