Submission #872162

# Submission time Handle Problem Language Result Execution time Memory
872162 2023-11-12T12:01:46 Z 12345678 Balloons (CEOI11_bal) C++17
30 / 100
136 ms 6688 KB
#include <bits/stdc++.h>

using namespace std;

const int nx=2e5+5;
double n, x[nx], mx[nx], dp[nx];
set<pair<double, long long>> ms;

int main()
{
    cin.tie(NULL)->sync_with_stdio(false);
    cin>>n;
    for (int i=1; i<=n; i++) cin>>x[i]>>mx[i];
    for (int i=1; i<=n; i++)
    {
        if (ms.empty()) dp[i]=mx[i], ms.insert({DBL_MAX, i});
        else
        {
            auto itr=ms.lower_bound({x[i], LLONG_MAX});
            dp[i]=min(double(mx[i]), ((x[i]-x[itr->second])*(x[i]-x[itr->second]))/(4*dp[itr->second]));
            while (dp[ms.begin()->second]<=dp[i]&&!ms.empty()) ms.erase(ms.begin());
            if (ms.empty()) ms.insert({DBL_MAX, i});
            else
            {
                long long l=ms.begin()->second;
                double a=dp[i]-dp[l], b=-2*(dp[i]*x[l]-dp[l]*x[i]), c=dp[i]*x[l]*x[l]-dp[l]*x[i]*x[i];
                double tmp=max((-b+sqrt(b*b-4*a*c))/(2*a), (-b-sqrt(b*b-4*a*c))/(2*a));
                ms.insert({tmp, i});
                while (!ms.empty()&&ms.begin()->second!=i) ms.erase(ms.begin());
            }
        }
        //cout<<i<<'\n';
        //for (auto [x, y]:ms) cout<<x<<' '<<y<<'\n';
    }
    for (int i=1; i<=n; i++) printf("%.3f\n", dp[i]);
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4440 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4444 KB 101st numbers differ - expected: '213.0000000000', found: '242.0000000000', error = '29.0000000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4444 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 4824 KB 1209th numbers differ - expected: '72.2820000000', found: '178.0000000000', error = '105.7180000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 35 ms 4932 KB 13945th numbers differ - expected: '0.0140000000', found: '7.0000000000', error = '6.9860000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 73 ms 5460 KB 7239th numbers differ - expected: '0.0590000000', found: '1.0000000000', error = '0.9410000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 80 ms 5584 KB 4645th numbers differ - expected: '0.0260000000', found: '8.0000000000', error = '7.9740000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 117 ms 6244 KB 1736th numbers differ - expected: '0.0050000000', found: '3.0000000000', error = '2.9950000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 136 ms 6688 KB 2718th numbers differ - expected: '2.2100000000', found: '3.0000000000', error = '0.7900000000'
2 Halted 0 ms 0 KB -