Submission #847886

# Submission time Handle Problem Language Result Execution time Memory
847886 2023-09-10T17:57:39 Z gtm7 Balloons (CEOI11_bal) C++17
100 / 100
165 ms 14928 KB
#include <bits/stdc++.h>
using namespace std;

int main()
{
    cout << fixed << setprecision(3);
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<pair<long double, long double>> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i].first >> a[i].second;
    }
    stack<pair<long double, long double>> s;
    long double d;
    vector<long double> ans(n);
    for (int i = 0; i < n; i++)
    {
        d = a[i].second;
        while (1)
        {
            if (s.empty())
            {
                s.push({a[i].first, d});
                ans[i] = d;
                break;
            }
            d = min(d, (s.top().first - a[i].first) * (s.top().first - a[i].first) / (4 * s.top().second));
            if (d < s.top().second)
            {
                s.push({a[i].first, d});
                ans[i] = d;
                break;
            }
            else
            {
                s.pop();
            }
        }
    }
    for (int i = 0; i < n; i++)
    {
        cout << ans[i] << "\n";
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 2 ms 344 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 17 ms 1368 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 41 ms 3376 KB 50000 numbers
2 Correct 40 ms 3932 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 84 ms 6064 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 96 ms 7132 KB 115362 numbers
2 Correct 94 ms 9040 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 130 ms 9084 KB 154271 numbers
2 Correct 151 ms 14928 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 159 ms 11464 KB 200000 numbers
2 Correct 165 ms 14928 KB 199945 numbers