Submission #988845

# Submission time Handle Problem Language Result Execution time Memory
988845 2024-05-26T12:53:38 Z _callmelucian Balloons (CEOI11_bal) C++14
60 / 100
244 ms 9296 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> tt;

#define all(a) a.begin(), a.end()
#define filter(a) a.erase(unique(all(a)), a.end())

const ld INF = 1e18;
const ld eps = 1e-6;
const int mn = 2e5 + 5;

ll x[mn], maxR[mn];
ld rad[mn];

bool ok (int j, int i, ld tryR) {
    ld tmp = (x[i] - x[j]) * (x[i] - x[j]);
    return tmp - 4 * rad[j] * tryR >= -eps;
}

ld calc (int j, int i, ld L = 0, ld R = INF) {
    if (abs(L - R) < eps) return L;
    ld mid = (L + R) / 2;
    if (ok(j, i, mid + eps)) return calc(j, i, mid + eps, R);
    return calc(j, i, L, mid);
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n; cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> x[i] >> maxR[i];
    rad[1] = maxR[1];

    cout << fixed << setprecision(9) << rad[1] << "\n";

    stack<int> st; st.push(1);
    for (int i = 2; i <= n; i++) {
        rad[i] = INF;
        int j = -1;
        while (st.size()) {
            j = st.top(); st.pop();
            ld cur = calc(j, i, 0, maxR[i]);
            rad[i] = min(rad[i], cur);
            if (rad[j] > rad[i]) {
                st.push(j);
                break;
            }
        }
        st.push(i);

        cout << rad[i] << "\n";
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 3 ms 344 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 28 ms 1136 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 62 ms 4440 KB 50000 numbers
2 Correct 65 ms 2508 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Incorrect 126 ms 5096 KB 17652nd numbers differ - expected: '7967.3370000000', found: '7967.3388042760', error = '0.0018042760'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 149 ms 5712 KB 19071st numbers differ - expected: '13152.0880000000', found: '13152.0839778300', error = '0.0040221700'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 202 ms 7468 KB 59437th numbers differ - expected: '10959.2470000000', found: '10959.2495464720', error = '0.0025464720'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 244 ms 9296 KB 2785th numbers differ - expected: '2962.3630000000', found: '2962.3609308520', error = '0.0020691480'
2 Halted 0 ms 0 KB -