Submission #1100296

# Submission time Handle Problem Language Result Execution time Memory
1100296 2024-10-13T12:45:08 Z michified Balloons (CEOI11_bal) C++17
100 / 100
493 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) {
    return min((x2 - x1) * (x2 - x1) / (4 * r1), r2);
}

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 508 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 8 ms 336 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 49 ms 848 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 121 ms 2048 KB 50000 numbers
2 Correct 122 ms 1724 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 248 ms 3508 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 307 ms 4168 KB 115362 numbers
2 Correct 303 ms 3844 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 382 ms 5448 KB 154271 numbers
2 Correct 493 ms 6480 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 483 ms 6636 KB 200000 numbers
2 Correct 489 ms 6216 KB 199945 numbers