Submission #485101

# Submission time Handle Problem Language Result Execution time Memory
485101 2021-11-06T07:47:44 Z dz001 Balloons (CEOI11_bal) C++11
10 / 100
407 ms 6580 KB
#include <bits/stdc++.h>
using namespace std;

#define sqr(x) (x)*(x)

const double eps=1e-3;
const int N=2e5+10;
double ans[N];
long long x[N],R[N];
int n;

double get(int i,int j){
    double l=0,r=R[i],kq=-1;
    for(int k=0;k<32;++k){
        double m=(l+r)/2.;
        double dist=sqr(m-ans[j])+sqr(x[j]-x[i]);
        if(sqr(m+ans[j])-dist<eps)kq=m,l=m;
        else r=m;
    }

    return kq;
}

signed main()
{
    ios::sync_with_stdio(NULL);
    cin.tie(nullptr);
    cout.precision(3);
    cout<<fixed;

    cin>>n;
    for(int i=0;i<n;++i)cin>>x[i]>>R[i];

    ans[0]=R[0];
    for(int i=1;i<n;++i){
        for(int j=max(0,i-10);j<i;++j){
            double tmp=get(i,j);
            // cout<<tmp<<endl;
            if(ans[i]>=tmp||ans[i]==0)ans[i]=tmp;
        }
    }

    for(int i=0;i<n;++i)cout<<ans[i]<<'\n';
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 332 KB 2nd numbers differ - expected: '252735385.4379999936', found: '252735385.2060000002', error = '0.2319999933'
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 332 KB 17th numbers differ - expected: '213.0000000000', found: '234.0000000000', error = '21.0000000000'
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 332 KB 397th numbers differ - expected: '137.2240000000', found: '137.2220000000', error = '0.0020000000'
# Verdict Execution time Memory Grader output
1 Incorrect 47 ms 848 KB 1207th numbers differ - expected: '458.2640000000', found: '458.2610000000', error = '0.0030000000'
# Verdict Execution time Memory Grader output
1 Incorrect 101 ms 1868 KB 13964th numbers differ - expected: '0.1510000000', found: '1.0000000000', error = '0.8490000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 206 ms 3516 KB 7258th numbers differ - expected: '7935.8510000000', found: '7953.0000000000', error = '17.1490000000'
# Verdict Execution time Memory Grader output
1 Incorrect 223 ms 3948 KB 4692nd numbers differ - expected: '0.3750000000', found: '2.7980000000', error = '2.4230000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 288 ms 5208 KB 1734th numbers differ - expected: '1856.0220000000', found: '1856.0140000000', error = '0.0080000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 407 ms 6580 KB 2716th numbers differ - expected: '22.1690000000', found: '22.1650000000', error = '0.0040000000'
2 Halted 0 ms 0 KB -