Submission #1116632

# Submission time Handle Problem Language Result Execution time Memory
1116632 2024-11-22T02:56:12 Z pemguimn Balloons (CEOI11_bal) C++17
50 / 100
109 ms 8264 KB
#include <bits/stdc++.h>

using namespace std;

const int N = 2e5 + 5;

int n, x[N], r[N];

long double ans[N];

long double calc(int i, int j){
    double x1 = x[i], y1 = ans[i];
    double x2 = x[j];
    return (x1 * x1 + x2 * x2 - 2 * x1 * x2 ) / (4 * y1);
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> x[i] >> r[i];
        ans[i] = r[i];
    }

    stack<int> st;
    for(int i = 1; i <= n; i++){
        long double reach = r[i];
        while(st.size()){
            reach = min(reach, calc(st.top(), i));
            if(reach < ans[st.top()]) break;
            st.pop();
        }
        ans[i] = reach;
        st.push(i);
    }

    for(int i = 1; i <= n; i++)
        cout << setprecision(3) << fixed << ans[i] << "\n";

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2384 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2640 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2384 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2552 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 11 ms 4688 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Incorrect 34 ms 5456 KB 9349th numbers differ - expected: '5056.0090000000', found: '5056.0070000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 65 ms 6404 KB 14707th 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 38 ms 5448 KB 16000th numbers differ - expected: '1631.0210000000', found: '1631.0190000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 109 ms 8264 KB 18470th numbers differ - expected: '191.9810000000', found: '191.9790000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 82 ms 6472 KB 44644th numbers differ - expected: '160.0020000000', found: '160.0000000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -