Submission #869629

# Submission time Handle Problem Language Result Execution time Memory
869629 2023-11-05T04:54:37 Z theghostking Balloons (CEOI11_bal) C++17
30 / 100
236 ms 11360 KB
#include <bits/stdc++.h>
using namespace std;
 
long double ck(long double posi, long double posj, long double ri){
    long double on = ((posj - posi) * (posj - posi));
    return (on) / (4.0L * ri);
}
 
int main() {
    int n;
    cin >> n;
    pair<long double, long double> bal[n];
    for (int i = 0; i < n; i++) {
        cin >> bal[i].first >> bal[i].second;
    }
    stack<pair<int, long double>> s;
    vector<long double> ans(n);
    ans[0] = bal[0].second;
    s.push({0, bal[0].second});
    for (int i = 1; i < n; i++) {
        ans[i] = bal[i].second;
        if (!s.empty()) {
            pair<int, long double> a = s.top();
            while (!s.empty()) {
                long double v = ck(bal[a.first].first, bal[i].first, a.second);
                ans[i] = min(ans[i], v);
                if (v >= ans[a.first]) {
                    s.pop();
                    if (!s.empty()) {
                        a = s.top();
                    }
                }
                else {
                    break;
                }
            }
        }
        if (!s.empty()) {
            pair<int, long double> a = s.top();
            ans[i] = min(ck(bal[a.first].first, bal[i].first, a.second), ans[i]);
        }
        s.push({i, ans[i]});
    }
    for (auto x : ans) {
        cout << fixed << setprecision(3) << x << '\n';
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 348 KB 504th numbers differ - expected: '160.9360000000', found: '163.0000000000', error = '2.0640000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 23 ms 1372 KB 653rd numbers differ - expected: '96.2810000000', found: '123.0000000000', error = '26.7190000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 60 ms 3156 KB 50000 numbers
2 Incorrect 61 ms 4076 KB 49903rd numbers differ - expected: '443977872.4679999948', found: '1000000000.0000000000', error = '556022127.5320000648'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 119 ms 5952 KB 14857th numbers differ - expected: '7169.6020000000', found: '7176.0000000000', error = '6.3980000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 139 ms 6848 KB 23610th numbers differ - expected: '1467.9600000000', found: '1471.0000000000', error = '3.0400000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 187 ms 8788 KB 12335th numbers differ - expected: '4957.2960000000', found: '4967.0000000000', error = '9.7040000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 236 ms 11360 KB 7553rd numbers differ - expected: '198.8980000000', found: '220.0000000000', error = '21.1020000000'
2 Halted 0 ms 0 KB -