Submission #1094857

# Submission time Handle Problem Language Result Execution time Memory
1094857 2024-09-30T17:04:19 Z Kodik Balloons (CEOI11_bal) C++17
30 / 100
124 ms 7608 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




ld check(ld lr, ld nx, ld lx){
    ld up = abs(nx-lx);
    ld denominator = 4*lr;
    return (up*up)/denominator;
}


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();
                mr = min(mr, check(lr,cor,lx));
                if(mr>lr){
                    st.pop();
                    if(st.empty()){
                        answer[i] = mr;
                        st.push({mr,cor});
                        break;
                    }
                }else{
                    st.push({mr,cor});
                    answer[i] = mr;
                    break;
                }
            }
        }
    }
    for(int i = 0; i < n; ++i){
        cout << answer[i] << '\n';
    }
    return 0;   
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 604 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB 1st numbers differ - expected: '247294217.0000000000', found: '247294000.0000000000', error = '217.0000000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 2 ms 348 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 1108 KB 2953rd numbers differ - expected: '1030.4380000000', found: '1030.4400000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 36 ms 2576 KB 251st numbers differ - expected: '15123.0020000000', found: '15123.0000000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 62 ms 4172 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 74 ms 4772 KB 511th numbers differ - expected: '4494.0050000000', found: '4494.0100000000', error = '0.0050000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 98 ms 5968 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 124 ms 7608 KB 248th numbers differ - expected: '2694.0020000000', found: '2694.0000000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -