Submission #923720

# Submission time Handle Problem Language Result Execution time Memory
923720 2024-02-07T15:46:58 Z vanea Balloons (CEOI11_bal) C++14
100 / 100
159 ms 7524 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

double calc_r(array<double, 2> a, double bx) {
    return (a[0] - bx) * (a[0] - bx) / (4 * a[1]);
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<double> ans(n);
    stack<array<double, 2>> s;
    for(int i = 0; i < n; i++) {
        double x, r;
        cin >> x >> r;
        double mx_r = r;
        while(!s.empty()) {
            array<double, 2> last = s.top();
            double ro_last_r = calc_r(last, x);
            mx_r = min(mx_r, ro_last_r);
            if(mx_r >= last[1]) {
                s.pop();
                continue;
            }
            else break;
        }
        s.push({x, mx_r});
        ans[i] = mx_r;
    }
    cout << fixed << setprecision(5);
    for(auto it : ans) cout << it << ' ';
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 2 ms 344 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 16 ms 1040 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 38 ms 2264 KB 50000 numbers
2 Correct 36 ms 2128 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 79 ms 3776 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 91 ms 4356 KB 115362 numbers
2 Correct 86 ms 4484 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 130 ms 5720 KB 154271 numbers
2 Correct 156 ms 7524 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 159 ms 6864 KB 200000 numbers
2 Correct 142 ms 7412 KB 199945 numbers