Submission #1073861

# Submission time Handle Problem Language Result Execution time Memory
1073861 2024-08-25T00:28:53 Z vjudge1 Mobile (BOI12_mobile) C++17
0 / 100
1000 ms 27572 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;

ld dist(ld x1, ld y1, ld x2, ld 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();

	ld ans = 0.0;
	ld ans_start = dist(pts[0].first, pts[0].second, 0,0);
	for(int i=0; i<n; i++){
		ans_start = min(ans_start, dist(pts[i].first,pts[i].second,0,0));
	}
	ld ans_end = dist(pts[0].first, pts[0].second, L,0);
	for(int i=0; i<n; i++){
		ans_end = min(ans_end, dist(pts[i].first,pts[i].second,L,0));
	}
	ans = max(ans_start,ans_end);

	const ld EPS = 1e-8;

	auto f = [&](ld 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]
		
		ld l=max(0LL, pts[i-1].first);
		ld r=min(L, pts[i].first);

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

		while(r-l > EPS){
			ld mid1 = l+(r-l)/3;
			ld 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;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 54 ms 2520 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 143 ms 2516 KB Output is correct
2 Correct 51 ms 1500 KB Output is correct
3 Incorrect 121 ms 3568 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 60 ms 1500 KB Output is correct
2 Correct 47 ms 2780 KB Output is correct
3 Incorrect 34 ms 1756 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 99 ms 2520 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 804 ms 9624 KB Output is correct
2 Correct 60 ms 592 KB Output is correct
3 Correct 61 ms 592 KB Output is correct
4 Incorrect 497 ms 9916 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 62 ms 592 KB Output is correct
2 Incorrect 434 ms 9412 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 959 ms 16828 KB Output is correct
2 Correct 68 ms 592 KB Output is correct
3 Correct 69 ms 9308 KB Output is correct
4 Incorrect 610 ms 27572 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 70 ms 592 KB Output is correct
2 Incorrect 502 ms 16852 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1018 ms 16824 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 85 ms 512 KB Output is correct
2 Incorrect 588 ms 16832 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1038 ms 16828 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 97 ms 592 KB Output is correct
2 Incorrect 659 ms 16824 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1044 ms 16976 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 133 ms 596 KB Output is correct
2 Incorrect 826 ms 16992 KB Output isn't correct
3 Halted 0 ms 0 KB -