답안 #1116627

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1116627 2024-11-22T02:46:55 Z pemguimn Balloons (CEOI11_bal) C++17
0 / 100
101 ms 6732 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];
        if(st.size()) reach = min(reach, calc(st.top(), i));
        ans[i] = reach;

        while(st.size() && calc(st.top(), i + 1) >= calc(i, i + 1)) st.pop();
        st.push(i);
    }

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

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2384 KB 5th numbers differ - expected: '17.1630000000', found: '99.0000000000', error = '81.8370000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2384 KB 2nd numbers differ - expected: '252735385.4379999936', found: '1000000000.0000000000', error = '747264614.5620000362'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2552 KB 3rd numbers differ - expected: '0.0420000000', found: '3.0000000000', error = '2.9580000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 2384 KB 114th numbers differ - expected: '39.0180000000', found: '56.0000000000', error = '16.9820000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 14 ms 4688 KB 196th numbers differ - expected: '100.7250000000', found: '111.0000000000', error = '10.2750000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 24 ms 4944 KB 9349th numbers differ - expected: '5056.0090000000', found: '5056.0070000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 54 ms 5624 KB 7236th numbers differ - expected: '0.0070000000', found: '7.0000000000', error = '6.9930000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 85 ms 6004 KB 4645th numbers differ - expected: '0.0260000000', found: '8.0000000000', error = '7.9740000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 92 ms 6216 KB 1730th numbers differ - expected: '5.6890000000', found: '6.8060000000', error = '1.1170000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 101 ms 6732 KB 2716th numbers differ - expected: '22.1690000000', found: '43.0000000000', error = '20.8310000000'
2 Halted 0 ms 0 KB -