Submission #815238

# Submission time Handle Problem Language Result Execution time Memory
815238 2023-08-08T13:24:38 Z serifefedartar Balloons (CEOI11_bal) C++17
100 / 100
199 ms 13148 KB
#include <bits/stdc++.h>
using namespace std;
 
#define fast ios::sync_with_stdio(0);cin.tie(0);
typedef long long ll;
#define f first
#define s second
#define MOD 1000000007
#define LOGN 12
#define MAXN 3000000
typedef long double ld;

ld find(ld r1, ll x1, ll x2) {
    ll d_sq = (x2 - x1) * (x2 - x1);
    ld ans = (d_sq * 1.0) / (4 * r1);
    return ans;
}

int main() {
    fast
    int n;
    cin >> n;

    vector<pair<ll,ll>> bal(n+1);
    vector<ld> ans(n+1);
    for (int i = 1; i <= n; i++)
        cin >> bal[i].f >> bal[i].s;

    stack<pair<ll, ld>> st; 
    for (int i = 1; i <= n; i++) {
        ans[i] = (ld)bal[i].s;
        while (!st.empty()) {
            pair<ll, ld> p = st.top();
            ld q = find(p.s, p.f, bal[i].f);
            ans[i] = min(ans[i], q);
            if (ans[i] >= p.s)
                st.pop();
            else
                break;
        }
        st.push({bal[i].f, ans[i]});
    }

    cout << setprecision(10) << fixed;
    for (int i = 1; i <= n; i++)
        cout << ans[i] << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 1 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 16 ms 1224 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 38 ms 3020 KB 50000 numbers
2 Correct 32 ms 3556 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 77 ms 5288 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 105 ms 5992 KB 115362 numbers
2 Correct 82 ms 7964 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 121 ms 7708 KB 154271 numbers
2 Correct 122 ms 13148 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 199 ms 9548 KB 200000 numbers
2 Correct 137 ms 13096 KB 199945 numbers