Submission #919095

# Submission time Handle Problem Language Result Execution time Memory
919095 2024-01-31T08:39:44 Z Em1L Balloons (CEOI11_bal) C++14
100 / 100
112 ms 5576 KB
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using pii = pair<int, double>;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << setprecision(3) << fixed;

    int n; cin >> n;

    stack < pii > st;

    auto GetR = [&](pii A, ll x) {
        auto [x_, r_] = A;

        return (x_ - x) * (x_ - x) / (4 * r_);
    };

    for (int i = 0, x, r; i < n; i++) {
        cin >> x >> r;

        double R = r;

        while (!st.empty()) {
            double curR = GetR(st.top(), x);

            R = min(R, curR);

            if (R >= st.top().second) {
                st.pop();
            } else {
                break;
            }
        }

        cout << R << "\n";

        st.push(make_pair(x, R));
    }
}

Compilation message

bal.cpp: In lambda function:
bal.cpp:16:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   16 |         auto [x_, r_] = A;
      |              ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 504 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 12 ms 600 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 29 ms 860 KB 50000 numbers
2 Correct 27 ms 1616 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 59 ms 1228 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 67 ms 1500 KB 115362 numbers
2 Correct 63 ms 3416 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 90 ms 1872 KB 154271 numbers
2 Correct 102 ms 5576 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 112 ms 1904 KB 200000 numbers
2 Correct 101 ms 5528 KB 199945 numbers