답안 #866260

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
866260 2023-10-25T16:28:51 Z dio_2 Balloons (CEOI11_bal) C++17
20 / 100
2000 ms 5888 KB
#include<bits/stdc++.h>
using namespace std;

using ld = long double;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int N;
	cin >> N;
	
	vector<int> x(N), r(N);
	vector<ld> ans(N);
	
	for(int i = 0;i < N;i++){
		cin >> x[i] >> r[i];
	}
	
	ans[0] = r[0];
	cout << fixed << setprecision(3) << ans[0] << '\n';
	
	#define X first
	#define Y second
	auto d = [&](pair<ld, ld> A, pair<ld, ld> B)->ld{
		return (A.X-B.X)*(A.X-B.X)+(A.Y-B.Y)*(A.Y-B.Y);
	};
	
	/*
	3
	0 9
	8 1
	13 7
	*/
	auto Calc = [&](int i, int j)->ld{
		ld radius_j = ans[j];
		pair<ld, ld> centre_j = {x[j], radius_j};
	
		ld lo = 0, hi = r[i], mid;
		
		//~ for(int rep = 0;rep < 70;++rep){
			//~ mid = (lo + hi) / 2;
			//~ ld radius_i = mid;
			//~ pair<ld, ld> centre_i = {x[i], radius_i};
			//~ if(d(centre_i, centre_j) >= (radius_i + radius_j) * (radius_i + radius_j))
				//~ lo = mid;
			//~ else 
				//~ hi = mid;
		//~ }
		
		//~ return (lo + hi) / 2;
		return (ld(x[i]*x[i]+x[j]*x[j]-2*x[i]*x[j])) / (4 * radius_j);
	};
	
	for(int i = 1;i < N;i++){
		ld use = r[i];
		for(int j = 0;j < i;j++){
			use = min(use, Calc(i, j));
		}
		ans[i] = use;
		cout << fixed << setprecision(3) << use << '\n';
	}
	
	return 0;
}

Compilation message

bal.cpp: In lambda function:
bal.cpp:37:16: warning: variable 'centre_j' set but not used [-Wunused-but-set-variable]
   37 |   pair<ld, ld> centre_j = {x[j], radius_j};
      |                ^~~~~~~~
bal.cpp:39:6: warning: unused variable 'lo' [-Wunused-variable]
   39 |   ld lo = 0, hi = r[i], mid;
      |      ^~
bal.cpp:39:14: warning: unused variable 'hi' [-Wunused-variable]
   39 |   ld lo = 0, hi = r[i], mid;
      |              ^~
bal.cpp:39:25: warning: unused variable 'mid' [-Wunused-variable]
   39 |   ld lo = 0, hi = r[i], mid;
      |                         ^~~
bal.cpp: In function 'int main()':
bal.cpp:25:7: warning: variable 'd' set but not used [-Wunused-but-set-variable]
   25 |  auto d = [&](pair<ld, ld> A, pair<ld, ld> B)->ld{
      |       ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB 10 numbers
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 356 KB 2nd numbers differ - expected: '252735385.4379999936', found: '0.9330000000', error = '252735384.5049999952'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 348 KB 505 numbers
# 결과 실행 시간 메모리 Grader output
1 Incorrect 13 ms 348 KB 216th numbers differ - expected: '204.7450000000', found: '-4362157.0549999997', error = '4362361.7999999998'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 705 ms 1272 KB 203rd numbers differ - expected: '482.0130000000', found: '-2497845.7940000002', error = '2498327.8070000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2062 ms 1852 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2050 ms 3128 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2029 ms 3524 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2027 ms 4408 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2048 ms 5888 KB Time limit exceeded
2 Halted 0 ms 0 KB -