Submission #1100291

# Submission time Handle Problem Language Result Execution time Memory
1100291 2024-10-13T12:40:38 Z michified Balloons (CEOI11_bal) C++17
60 / 100
574 ms 6640 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.000001) {
        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.000001;
    }
    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;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 2 ms 336 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 6 ms 336 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 57 ms 1000 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 152 ms 1864 KB 50000 numbers
2 Correct 150 ms 2892 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Incorrect 288 ms 3656 KB 52682nd numbers differ - expected: '7451.3900000000', found: '7451.3880000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 335 ms 4168 KB 68181st numbers differ - expected: '13205.4230000000', found: '13205.4250000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 452 ms 5448 KB 18640th numbers differ - expected: '5260.0460000000', found: '5260.0440000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 574 ms 6640 KB 2785th numbers differ - expected: '2962.3630000000', found: '2962.3610000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -