Submission #815225

# Submission time Handle Problem Language Result Execution time Memory
815225 2023-08-08T13:18:50 Z serifefedartar Balloons (CEOI11_bal) C++17
0 / 100
138 ms 13740 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);
            if (q < ans[i]) {
                break;
            } else {
                st.pop();
                ans[i] = q;
            }
        }
        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 Incorrect 0 ms 212 KB 2nd numbers differ - expected: '4.1670000000', found: '7.0000000000', error = '2.8330000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB 2nd numbers differ - expected: '252735385.4379999936', found: '1000000000.0000000000', error = '747264614.5620000362'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB 2nd numbers differ - expected: '0.0010000000', found: '3.0000000000', error = '2.9990000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 340 KB 2nd numbers differ - expected: '122.0020000000', found: '123.0000000000', error = '0.9980000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 1620 KB 2nd numbers differ - expected: '212.0010000000', found: '213.0000000000', error = '0.9990000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 35 ms 3288 KB 2nd numbers differ - expected: '15398.0000000000', found: '24984.0000000000', error = '9586.0000000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 67 ms 6444 KB 2nd numbers differ - expected: '7937.0000000000', found: '10352.0000000000', error = '2415.0000000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 78 ms 7392 KB 2nd numbers differ - expected: '5059.0000000000', found: '5060.0000000000', error = '1.0000000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 109 ms 9860 KB 2nd numbers differ - expected: '1873.0000000000', found: '1874.0000000000', error = '1.0000000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 138 ms 13740 KB 2nd numbers differ - expected: '2961.0000000000', found: '2962.0000000000', error = '1.0000000000'
2 Halted 0 ms 0 KB -