Submission #921184

# Submission time Handle Problem Language Result Execution time Memory
921184 2024-02-03T12:14:48 Z 0x34c Balloons (CEOI11_bal) C++17
100 / 100
160 ms 5716 KB
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define pdd pair<double, double>
#define endl '\n'

using namespace std;

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

    int N;
    cin >> N;

    auto calc_r = [](pdd &a, double x) {
        return ((x - a.first)*(x - a.first))/(4*a.second);
    };

    stack<pdd> st;
    for(int i = 0; i < N; i++) {
        double x, r;
        cin >> x >> r;

        double max_r = r;
        while(!st.empty()) {
            pdd tp = st.top();

            max_r = min(max_r, calc_r(tp, x));
            if(max_r >= tp.second)
                st.pop();
            else break;
        }
        st.push({x, max_r});
        cout << fixed << setprecision(4) << max_r << endl;
    }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 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 2 ms 600 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 21 ms 600 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 40 ms 860 KB 50000 numbers
2 Correct 45 ms 1680 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 86 ms 1452 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 98 ms 1608 KB 115362 numbers
2 Correct 103 ms 3668 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 127 ms 2036 KB 154271 numbers
2 Correct 153 ms 5576 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 160 ms 2116 KB 200000 numbers
2 Correct 158 ms 5716 KB 199945 numbers