# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
998472 |
2024-06-14T03:29:29 Z |
hippo123 |
Balloons (CEOI11_bal) |
C++17 |
|
460 ms |
9816 KB |
#include <bits/stdc++.h>
using namespace std;
#define pr pair<double, double>
#define ll long long
#define pb push_back
#define f first
#define s second
vector<double> x, r;
vector<pr> xr;
bool check(double mid, int bb, int be){
bool judge=false;
for (int i=bb; i<be; i++){
double rr=(mid+r[xr[bb].s])*(mid+r[xr[bb].s]);
double dist1=(mid-r[xr[bb].s])*(mid-r[xr[bb].s])+(x[be]-x[xr[bb].s])*(x[be]-x[xr[bb].s]);
if(rr>=dist1){
judge=true; break;
}
}
return judge;
}
int main(){
int n; cin>>n;
x.resize(n); r.resize(n); xr.resize(n);
for (int i=0; i<n; i++) {
cin>>x[i]>>r[i];
xr[i].f=x[i]+r[i]; xr[i].s=i;
}
sort(xr.begin(), xr.end());
vector<double> ans(n);
for (int i=0; i<n; i++){
if(i==0) {
ans[i]=r[i];
continue;
}
//
pr node={x[i]-r[i], 0};
int pos=lower_bound(xr.begin(), xr.begin()+n, node)-xr.begin();
pos=xr[pos].s; // this one cannot exceed
if(pos==i) {ans[i]=r[i]; continue;}
double lft=0; double rht=r[i];
while(rht-lft>0.00001){
double mid=lft+(rht-lft)/2;
if(check(mid, pos, i)) {
rht=mid;
}
else lft=mid;
}
ans[i]=lft;
}
cout << fixed <<setprecision(3);
for (int i=0; i<n; i++) cout<<ans[i]<<endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
6th numbers differ - expected: '21.0000000000', found: '15.7600000000', error = '5.2400000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
2 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
348 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 |
5 ms |
348 KB |
3rd numbers differ - expected: '121.0000000000', found: '120.0180000000', error = '0.9820000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
47 ms |
1372 KB |
3rd numbers differ - expected: '211.0000000000', found: '210.0110000000', error = '0.9890000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
120 ms |
2772 KB |
3rd numbers differ - expected: '15396.0000000000', found: '9489.3930000000', error = '5906.6070000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
246 ms |
5204 KB |
3rd numbers differ - expected: '7936.0000000000', found: '6084.6240000000', error = '1851.3760000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
287 ms |
5972 KB |
6th numbers differ - expected: '5053.0000000000', found: '5052.0000000000', error = '1.0000000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
367 ms |
7760 KB |
3rd numbers differ - expected: '1872.0000000000', found: '1871.0010000000', error = '0.9990000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
460 ms |
9816 KB |
3rd numbers differ - expected: '2960.0000000000', found: '2959.0010000000', error = '0.9990000000' |
2 |
Halted |
0 ms |
0 KB |
- |