Submission #869626

# Submission time Handle Problem Language Result Execution time Memory
869626 2023-11-05T04:45:42 Z theghostking Balloons (CEOI11_bal) C++17
10 / 100
239 ms 10068 KB
#include <bits/stdc++.h>
using namespace std;

double ck(double posi, double posj, double ri){
    int on = ((posj-posi)*(posj-posi));
    //cout << posi << " " << posj << " " << ri << "   " << on << " " << (1.0*on)/(4.0*ri) << "\n\n"; 
    return (1.0*on)/(4.0*ri);
}

int main() {
    int n;
    cin >> n;
    pair<double,double> bal[n];
    for (int i = 0; i<n; i++){
        cin >> bal[i].first >> bal[i].second;
    }
    stack<pair<int,double>> s;
    //index, how much it is inflated
    //monotonic stack
    vector<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,double> a = s.top();
            
            /*while ((!s.empty()) && (ck(a.first,bal[i].first,a.second) >= bal[i].second)){
                s.pop();
                if (!s.empty()){
                    a = s.top();
                }
            }*/
            while (!s.empty()){
                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,double> a = s.top();
            ans[i] = min(ck(bal[a.first].first,bal[i].first,a.second),bal[i].second);
        }
        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 1 ms 348 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB 2nd numbers differ - expected: '252735385.4379999936', found: '-2.1710000000', error = '252735387.6089999974'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB 14th numbers differ - expected: '2.6090000000', found: '7.1410000000', error = '4.5320000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 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 Incorrect 61 ms 2644 KB 4th numbers differ - expected: '15396.0000000000', found: '-34866.2760000000', error = '50262.2760000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 120 ms 5168 KB 11th numbers differ - expected: '7923.0000000000', found: '-67692.7130000000', error = '75615.7130000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 138 ms 6160 KB 13th numbers differ - expected: '5046.0000000000', found: '-106290.0240000000', error = '111336.0240000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 183 ms 8016 KB 14th numbers differ - expected: '1861.0000000000', found: '-286483.9450000000', error = '288344.9450000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 239 ms 10068 KB 10th numbers differ - expected: '2952.0000000000', found: '-181314.0480000000', error = '184266.0480000000'
2 Halted 0 ms 0 KB -