Submission #628410

# Submission time Handle Problem Language Result Execution time Memory
628410 2022-08-13T11:39:08 Z shubham20_03 Balloons (CEOI11_bal) C++17
100 / 100
166 ms 13732 KB
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define deb(x) cout<<#x<<'='<<x<<'\n';
#define deb2(x,y) cout<<#x<<'='<<x<<", "<<#y<<'='<<y<<'\n';
#define int long long
#define all(x) (x).begin(), (x).end()
#define pii pair<int, int>
#define pb push_back
#define f first
#define s second
#define sz(x) (int)(x).size()
#define ld long double
const long double PI = acos(-1);
const int mod = 1e9 + 7, inf = 1e18;
const int D = 2e5 + 10;

signed main() {
    fastio

    // freopen("../input1.txt", "r", stdin);
    // freopen("../output1.txt", "w", stdout);

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

    ld ans[n];

    auto get_r = [&](int p, int q) {
        return (x[q] - x[p]) * (x[q] - x[p]) / (4.0 * ans[p]);
    };

    stack<int> stk;
    for (int i = 0; i < n; i++) {
        ans[i] = r[i];
        while (stk.size()) {
            ld cr = get_r(stk.top(), i);
            ans[i] = min(ans[i], cr);
            if (ans[i] >= ans[stk.top()])
                stk.pop();
            else break;
        }
        stk.push(i);
    }

    for (int i = 0; i < n; i++)
        cout << setprecision(13) << ans[i] << '\n';

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 2 ms 340 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 17 ms 1200 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 49 ms 2636 KB 50000 numbers
2 Correct 39 ms 2668 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 87 ms 4844 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 98 ms 5476 KB 115362 numbers
2 Correct 90 ms 8388 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 135 ms 7148 KB 154271 numbers
2 Correct 144 ms 13732 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 166 ms 9204 KB 200000 numbers
2 Correct 140 ms 13644 KB 199945 numbers