Submission #1103795

# Submission time Handle Problem Language Result Execution time Memory
1103795 2024-10-21T18:12:08 Z peteza Balloons (CEOI11_bal) C++14
20 / 100
132 ms 2052 KB
#include <bits/stdc++.h>
using namespace std;

int n, x;
stack<pair<int, double>> stk;
double r;

double ry(double rx, long long x, long long y) {
    return ((x*x-2*x*y+y*y)/rx)/4;
}

double cmp(pair<int, double> e1, pair<int, double> e2, long long y) {
    return (e2.second)*(1ll*e1.first*e1.first-2ll*e1.first*y+y*y) <= (e1.second)*(1ll*e2.first*e2.first-2ll*e2.first*y+y*y);
}

int main() {
    cin.tie(0) -> sync_with_stdio(0);
    cin >> n;
    while(n--) {
        cin >> x >> r;
        while(stk.size() > 1) {
            auto e2 = stk.top(); stk.pop(); auto e1 = stk.top(); 
            if((1ll*e2.first*e2.first-2ll*x*e2.first+1ll*x*x) >= 4*e2.second*r && cmp(e1, e2, x)) continue;
            else {
                stk.push(e2);
                break;
            }
        }
        if(stk.empty()) stk.emplace(x, r);
        else stk.emplace(x, min(ry(stk.top().second, stk.top().first, x), r));
        while(stk.size() > 1) {
            auto e2 = stk.top(); stk.pop(); auto e1 = stk.top(); 
            if(e1.second <= e2.second) {stk.pop(); stk.push(e2); continue;}
            else { stk.push(e2); break; }
        }
        cout << fixed << setprecision(3) << stk.top().second << '\n';
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB 12th numbers differ - expected: '5.1130000000', found: '5.3100000000', error = '0.1970000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 336 KB 397th numbers differ - expected: '137.2240000000', found: '158.7600000000', error = '21.5360000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 592 KB 196th numbers differ - expected: '100.7250000000', found: '109.4560000000', error = '8.7310000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 37 ms 900 KB 13946th numbers differ - expected: '0.0440000000', found: '2215.6580000000', error = '2215.6140000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 64 ms 1352 KB 7238th numbers differ - expected: '0.0400000000', found: '927.9360000000', error = '927.8960000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 75 ms 1608 KB 4652nd numbers differ - expected: '0.4350000000', found: '0.5930000000', error = '0.1580000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 102 ms 1864 KB 1730th numbers differ - expected: '5.6890000000', found: '6.8060000000', error = '1.1170000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 132 ms 2052 KB 2731st numbers differ - expected: '2.4630000000', found: '5.8260000000', error = '3.3630000000'
2 Halted 0 ms 0 KB -