Submission #998471

# Submission time Handle Problem Language Result Execution time Memory
998471 2024-06-14T03:21:28 Z hippo123 Balloons (CEOI11_bal) C++17
10 / 100
2000 ms 8016 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]);

		double rr=(mid+r[i])*(mid+r[i]);
		
		double dist1=(mid-r[i])*(mid-r[i])+(x[be]-x[i])*(x[be]-x[i]);


		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; 
	}
	
	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(); 
		//cout<<" i= "<<i<<endl;
		//cout<<" pos= "<<pos<<endl;
		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;
			//cout<<" lft/rht/mid= "<<lft<<" "<<rht<<" "<<mid<<endl;
			
			if(check(mid, 0, 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 5th numbers differ - expected: '17.1630000000', found: '4.3710000000', error = '12.7920000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 348 KB 5th numbers differ - expected: '0.1170000000', found: '0.0830000000', error = '0.0340000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 48 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 Execution timed out 2064 ms 1116 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2007 ms 2264 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2055 ms 4180 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2032 ms 4944 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2068 ms 6232 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2039 ms 8016 KB Time limit exceeded
2 Halted 0 ms 0 KB -