Submission #1103792

# Submission time Handle Problem Language Result Execution time Memory
1103792 2024-10-21T17:52:17 Z peteza Balloons (CEOI11_bal) C++14
20 / 100
128 ms 7240 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));
        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 17th numbers differ - expected: '213.0000000000', found: '234.0000000000', error = '21.0000000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 336 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 14 ms 1104 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 34 ms 2128 KB 14174th numbers differ - expected: '0.7720000000', found: '1.3710000000', error = '0.5990000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 87 ms 4116 KB 7447th numbers differ - expected: '0.9750000000', found: '8.0000000000', error = '7.0250000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 78 ms 4680 KB 4793rd numbers differ - expected: '0.9540000000', found: '10.6220000000', error = '9.6680000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 118 ms 6476 KB 1734th numbers differ - expected: '1856.0220000000', found: '1865.0000000000', error = '8.9780000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 128 ms 7240 KB 2735th numbers differ - expected: '1883.4630000000', found: '1899.0000000000', error = '15.5370000000'
2 Halted 0 ms 0 KB -