Submission #872119

# Submission time Handle Problem Language Result Execution time Memory
872119 2023-11-12T10:39:42 Z 12345678 Balloons (CEOI11_bal) C++17
20 / 100
167 ms 12980 KB
#include <bits/stdc++.h>

using namespace std;

const int nx=2e5+5;
double n, x[nx], mx[nx], dp[nx];
set<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]);
}

/*
7
0 10
20 100
30 100
32 100
33 100
100 100
400 1000
*/
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 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 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 2 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 15 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 38 ms 5832 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 80 ms 7508 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 95 ms 8644 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 140 ms 11348 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 167 ms 12980 KB 12th numbers differ - expected: '2950.0000000000', found: '2952.0000000000', error = '2.0000000000'
2 Halted 0 ms 0 KB -