Submission #1071600

# Submission time Handle Problem Language Result Execution time Memory
1071600 2024-08-23T09:15:44 Z BoopyTheNoob Balloons (CEOI11_bal) C++14
10 / 100
105 ms 13272 KB
#include <bits/stdc++.h>
using namespace std;

int n;

void subtask1 (vector<pair<double, double>> info) {
    vector<double> ans(n);
    ans[0] = info[0].second;
    for (int i = 1; i < n; i++) {
        double pans = 1e9;
        for (int j = 0; j < i; j++)
            pans = min(pans, (info[i].first - info[j].first) * (info[i].first - info[j].first) / (4 * ans[j]));
        ans[i] = min(pans, info[i].second);
    }
    for (auto x: ans) printf("%.3lf\n", x);
}

void subtask2 (vector<pair<double, double>> info) {
    vector<double> ans(n);
    vector<pair<double, double>> s;
    for (int i = 0; i < n; i++) {
        double estimate = info[i].second;
        while (s.size()) {
            double x1mx2 = (info[i].first - s.back().first);
            estimate = x1mx2 * x1mx2 / (4 * s.back().second);
            //cout << s.back().second << " " << estimate << " ";
            if (estimate <= info[i].second) s.pop_back();
            else break;
        }
        ans[i] = min(estimate, info[i].second);
        s.push_back({info[i].first, ans[i]});
        printf("%.3lf\n", ans[i]);
    }
}

int main (void) {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n;
    vector<pair<double, double>> info(n);
    for (int i = 0; i < n; i++) {
        cin >> info[i].first >> info[i].second;
    }
    subtask2(info);
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 452 KB 4th numbers differ - expected: '1.8420000000', found: '87.0000000000', error = '85.1580000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB 3rd numbers differ - expected: '0.0420000000', found: '3.0000000000', error = '2.9580000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 512 KB 6th numbers differ - expected: '116.0020000000', found: '117.0000000000', error = '0.9980000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 18 ms 1628 KB 11th numbers differ - expected: '201.0010000000', found: '202.0000000000', error = '0.9990000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 3668 KB 5th numbers differ - expected: '15395.0000000000', found: '15396.0000000000', error = '1.0000000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 78 ms 6868 KB 14th numbers differ - expected: '7919.0000000000', found: '7920.0000000000', error = '1.0000000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 66 ms 7892 KB 5th numbers differ - expected: '5054.0000000000', found: '5055.0000000000', error = '1.0000000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 85 ms 10388 KB 15th numbers differ - expected: '1860.0000000000', found: '1861.0000000000', error = '1.0000000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 105 ms 13272 KB 11th numbers differ - expected: '2951.0000000000', found: '2952.0000000000', error = '1.0000000000'
2 Halted 0 ms 0 KB -