Submission #485112

# Submission time Handle Problem Language Result Execution time Memory
485112 2021-11-06T08:13:22 Z dz001 Balloons (CEOI11_bal) C++11
20 / 100
1918 ms 6464 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-100);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 204 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 Correct 6 ms 332 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 368 KB 397th numbers differ - expected: '137.2240000000', found: '137.2220000000', error = '0.0020000000'
# Verdict Execution time Memory Grader output
1 Incorrect 207 ms 908 KB 1207th numbers differ - expected: '458.2640000000', found: '458.2610000000', error = '0.0030000000'
# Verdict Execution time Memory Grader output
1 Incorrect 473 ms 1892 KB 27818th numbers differ - expected: '4.2990000000', found: '10.0000000000', error = '5.7010000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 933 ms 3536 KB 7966th numbers differ - expected: '13.4810000000', found: '32.3600000000', error = '18.8790000000'
# Verdict Execution time Memory Grader output
1 Incorrect 1100 ms 4076 KB 5083rd numbers differ - expected: '5067.4220000000', found: '5075.0000000000', error = '7.5780000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1444 ms 5216 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 1918 ms 6464 KB 2716th numbers differ - expected: '22.1690000000', found: '22.1650000000', error = '0.0040000000'
2 Halted 0 ms 0 KB -