Submission #1103794

# Submission time Handle Problem Language Result Execution time Memory
1103794 2024-10-21T17:56:45 Z peteza Balloons (CEOI11_bal) C++14
20 / 100
130 ms 1600 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.00;
}

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 << 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 Incorrect 1 ms 336 KB 1st numbers differ - expected: '247294217.0000000000', found: '247294000.0000000000', error = '217.0000000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 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 4 ms 336 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 592 KB 2953rd numbers differ - expected: '1030.4380000000', found: '1030.4400000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 36 ms 784 KB 251st numbers differ - expected: '15123.0020000000', found: '15123.0000000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 77 ms 944 KB 285th numbers differ - expected: '7629.0020000000', found: '7629.0000000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 76 ms 1096 KB 511th numbers differ - expected: '4494.0050000000', found: '4494.0100000000', error = '0.0050000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 103 ms 1352 KB 164th numbers differ - expected: '1698.0020000000', found: '1698.0000000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 130 ms 1600 KB 248th numbers differ - expected: '2694.0020000000', found: '2694.0000000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -