답안 #1073857

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1073857 2024-08-25T00:18:37 Z vjudge1 Mobile (BOI12_mobile) C++17
0 / 100
648 ms 29120 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

double dist(double x1, double y1, double x2, double y2){
	return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);

	int n;
	ll L;
	cin >> n >> L;
	
	vector <pair<ll,ll>> pts;
	for(int i=0; i<n; i++){
		ll x, y;
		cin >> x >> y;
		if(!pts.empty() && x == pts.back().first){
			pts.back().second = min(pts.back().second, abs(y));
		}
		else{
			pts.push_back({x,abs(y)});
		}
	}
	n = pts.size();

	double ans = max(
			dist(pts[0].first,pts[0].second,0,0),
			dist(pts[n-1].first, pts[n-1].second, L, 0));


	const double EPS = 1e-7;

	auto f = [&](double x, int i){
		return max(
				dist(x,0,pts[i-1].first,pts[i-1].second),
				dist(x,0,pts[i].first,pts[i].second));
	};

	for(int i=1; i<n; i++){
		// ternary search x* between pts[i-1], pts[i]
		
		double l=max(0LL, pts[i-1].first);
		double r=min(L, pts[i].first);

		/*
		for(double xt = l; xt <= r; xt+=0.5){
			cout << "xt: " << xt << ' ' << f(xt, i) << endl;
		}
		*/

		while(r-l > EPS){
			double mid1 = l+(r-l)/3;
			double mid2 = l+2*(r-l)/3;
			
			if(f(mid2,i)-f(mid1,i) >= 0) r = mid2;
			else l = mid1;
		}
		ans = max(ans, f(l,i));
	}

	ans = sqrt(ans);
	cout << fixed << setprecision(6) << ans << '\n';
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 27 ms 3288 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 1372 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 60 ms 3288 KB Output is correct
2 Incorrect 25 ms 2520 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 25 ms 3036 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 46 ms 3796 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 325 ms 12604 KB Output is correct
2 Correct 64 ms 8336 KB Output is correct
3 Correct 57 ms 7856 KB Output is correct
4 Incorrect 237 ms 17740 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 66 ms 8916 KB Output is correct
2 Incorrect 199 ms 14776 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 387 ms 21832 KB Output is correct
2 Incorrect 70 ms 9952 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 71 ms 10324 KB Output is correct
2 Incorrect 232 ms 24280 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 451 ms 22456 KB Output is correct
2 Incorrect 80 ms 11344 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 110 ms 12116 KB Output is correct
2 Incorrect 269 ms 24256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 526 ms 23692 KB Output is correct
2 Incorrect 92 ms 12828 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 99 ms 13852 KB Output is correct
2 Incorrect 315 ms 24240 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 648 ms 24908 KB Output is correct
2 Incorrect 122 ms 16092 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 158 ms 16992 KB Output is correct
2 Incorrect 385 ms 29120 KB Output isn't correct
3 Halted 0 ms 0 KB -