Submission #872121

# Submission time Handle Problem Language Result Execution time Memory
872121 2023-11-12T10:41:26 Z 12345678 Balloons (CEOI11_bal) C++17
20 / 100
191 ms 12988 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});
            }
        }
    }
    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 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 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 16 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 43 ms 5972 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 83 ms 7468 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 97 ms 8652 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 11472 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 191 ms 12988 KB 12th numbers differ - expected: '2950.0000000000', found: '2952.0000000000', error = '2.0000000000'
2 Halted 0 ms 0 KB -