Submission #1105026

# Submission time Handle Problem Language Result Execution time Memory
1105026 2024-10-25T07:55:19 Z ezzzay Balloons (CEOI11_bal) C++14
0 / 100
538 ms 8492 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ff first
#define ss second
#define pb push_back
const int N=3e5+5;
double x[N],r[N];
double p[N];
bool check(int i, int j, double R){
    double xj=x[j],yj=p[j],rj=p[j];
    double xi=x[i],yi=R,ri=R;
    double d=(xi-xj)*(xi-xj)+(R-yj)*(R-yj);
    double f=R+ri;
    if(f*f<=d){
        return 1;
    }
    else{
        return 0;
    }
}
signed main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>x[i]>>r[i];
    }
    p[1]=r[1];
    for(int i=2;i<=n;i++){
        double lo=0,hi=r[i];
        while(hi>=lo){
            double mid=(hi+lo)/2;
            bool u=1;
            for(int j=i-1;j<i;j++){
                u&=check(i,j,mid);
            }
            if(u){
                lo=mid+0.00001;
            }
            else{
                hi=mid-0.00001;
            }
        }
        p[i]=hi;
    }
    for(int i=1;i<=n;i++){
        cout<<fixed<<setprecision(3)<<p[i]<<endl;
    }
}

Compilation message

bal.cpp: In function 'bool check(long long int, long long int, double)':
bal.cpp:11:28: warning: unused variable 'rj' [-Wunused-variable]
   11 |     double xj=x[j],yj=p[j],rj=p[j];
      |                            ^~
bal.cpp:12:20: warning: unused variable 'yi' [-Wunused-variable]
   12 |     double xi=x[i],yi=R,ri=R;
      |                    ^~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4432 KB 2nd numbers differ - expected: '4.1670000000', found: '7.0000000000', error = '2.8330000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4432 KB 2nd numbers differ - expected: '252735385.4379999936', found: '250003669.0379999876', error = '2731716.4000000060'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 4432 KB 2nd numbers differ - expected: '0.0010000000', found: '3.0000000000', error = '2.9990000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 4432 KB 2nd numbers differ - expected: '122.0020000000', found: '122.5000000000', error = '0.4980000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 52 ms 4752 KB 2nd numbers differ - expected: '212.0010000000', found: '212.5000000000', error = '0.4990000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 142 ms 7100 KB 2nd numbers differ - expected: '15398.0000000000', found: '15398.5000000000', error = '0.5000000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 264 ms 8492 KB 2nd numbers differ - expected: '7937.0000000000', found: '7937.5000000000', error = '0.5000000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 304 ms 7604 KB 2nd numbers differ - expected: '5059.0000000000', found: '5059.5000000000', error = '0.5000000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 419 ms 8112 KB 2nd numbers differ - expected: '1873.0000000000', found: '1873.5000000000', error = '0.5000000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 538 ms 8264 KB 2nd numbers differ - expected: '2961.0000000000', found: '2961.5000000000', error = '0.5000000000'
2 Halted 0 ms 0 KB -