답안 #1100290

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1100290 2024-10-13T12:40:02 Z michified Balloons (CEOI11_bal) C++17
10 / 100
532 ms 6636 KB
#include <bits/stdc++.h>
#define ll long long
#define db double
#define lid id * 2 + 1
#define rid id * 2 + 2
using namespace std;

const ll mod = 1e9 + 7;

db bestR(db x1, db r1, db x2, db r2) {
    db l = 0, r = r2 + 1;
    while (l < r - 0.001) {
        db mid = (l + r) / 2;
        if (sqrt((x2 - x1) * (x2 - x1) + abs(r1 - mid) * abs(r1 - mid)) >= r1 + mid) l = mid;
        else r = mid - 0.001;
    }
    return min(r2, l);
}

int main() {
    // ifstream cin("balancing.in");
    // ofstream cout("balancing.out");

    int n, i;
    cin >> n;
    vector<db> x(n), r(n);
    for (i = 0; i < n; i++) cin >> x[i] >> r[i];
    vector<db> ans(n);
    stack<int> st;
    ans[0] = r[0];
    st.push(0);
    for (i = 1; i < n; i++) {
        db res = r[i];
        while (not st.empty()) {
            res = min(res, bestR(x[st.top()], ans[st.top()], x[i], r[i]));
            if (res >= ans[st.top()]) st.pop();
            else break;
        }
        ans[i] = res;
        st.push(i);
    }
    cout << fixed << setprecision(3);
    for (i = 0; i < n; i++) cout << ans[i] << endl;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 336 KB 2nd numbers differ - expected: '4.1670000000', found: '4.1650000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB 2 numbers
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 336 KB 6th numbers differ - expected: '213.0000000000', found: '212.9980000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 336 KB 11th numbers differ - expected: '111.0000000000', found: '110.9980000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 54 ms 964 KB 4th numbers differ - expected: '210.0010000000', found: '209.9990000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 138 ms 1864 KB 37th numbers differ - expected: '15363.0000000000', found: '15362.9980000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 333 ms 3668 KB 6th numbers differ - expected: '7933.0000000000', found: '7932.9980000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 323 ms 4032 KB 7th numbers differ - expected: '5052.0000000000', found: '5051.9980000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 416 ms 5456 KB 5th numbers differ - expected: '1870.0000000000', found: '1869.9980000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 532 ms 6636 KB 15th numbers differ - expected: '2947.0000000000', found: '2946.9980000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -