Submission #872117

# Submission time Handle Problem Language Result Execution time Memory
872117 2023-11-12T10:36:21 Z 12345678 Balloons (CEOI11_bal) C++17
20 / 100
159 ms 12908 KB
#include <bits/stdc++.h>

using namespace std;

const int nx=2e5+5;
double n, x[nx], mx[nx], dp[nx];
multiset<pair<double, int>> 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], INT_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
            {
                int 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});
            }
        }
        //cout<<i<<'\n';
        //for (auto [x, y]:ms) cout<<x<<' '<<y<<'\n';
    }
    for (int i=1; i<=n; i++) printf("%.3f\n", dp[i]);
}

/*
3
0 10
10 1
20 100
*/
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4440 KB 14th numbers differ - expected: '2.6090000000', found: '7.0410000000', error = '4.4320000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 4444 KB 7th numbers differ - expected: '115.0000000000', found: '117.0000000000', error = '2.0000000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 18 ms 4956 KB 12th numbers differ - expected: '200.0000000000', found: '202.0000000000', error = '2.0000000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 40 ms 5936 KB 41st numbers differ - expected: '15358.0000000000', found: '22549.0000000000', error = '7191.0000000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 82 ms 7500 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 104 ms 8588 KB 6th numbers differ - expected: '5053.0000000000', found: '5055.0000000000', error = '2.0000000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 127 ms 11380 KB 49th numbers differ - expected: '1824.0000000000', found: '1826.0000000000', error = '2.0000000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 159 ms 12908 KB 12th numbers differ - expected: '2950.0000000000', found: '2952.0000000000', error = '2.0000000000'
2 Halted 0 ms 0 KB -