Submission #1103793

# Submission time Handle Problem Language Result Execution time Memory
1103793 2024-10-21T17:55:00 Z peteza Balloons (CEOI11_bal) C++14
30 / 100
131 ms 1868 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(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 504 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 508 KB 53rd numbers differ - expected: '213.0000000000', found: '235.0000000000', error = '22.0000000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 336 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 592 KB 4165th numbers differ - expected: '463.3780000000', found: '468.0000000000', error = '4.6220000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 40 ms 848 KB 26317th numbers differ - expected: '1.1140000000', found: '16.4820000000', error = '15.3680000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 77 ms 1352 KB 7458th numbers differ - expected: '1.9040000000', found: '8.0000000000', error = '6.0960000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 81 ms 1608 KB 4889th numbers differ - expected: '0.7110000000', found: '8.0000000000', error = '7.2890000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 104 ms 1868 KB 40692nd numbers differ - expected: '5543.6460000000', found: '5559.0000000000', error = '15.3540000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 131 ms 1864 KB 4263rd numbers differ - expected: '0.6980000000', found: '4.0000000000', error = '3.3020000000'
2 Halted 0 ms 0 KB -