Submission #477075

# Submission time Handle Problem Language Result Execution time Memory
477075 2021-09-30T06:07:22 Z qwerty1234 Mobile (BOI12_mobile) C++17
50 / 100
1000 ms 48148 KB
#include <bits/stdc++.h>

#define ll long long

using namespace std;

bool check(double maxDist, vector<pair<double, double>> &transceivers, ll N, ll L) {
	vector<pair<double, double>> bounds;
	double covered = 0;
	for (int i = 0; i < N; i++) {
		double ySquared = transceivers[i].second * transceivers[i].second;
		double hypoSquared = maxDist * maxDist;
		if (hypoSquared - ySquared < 0) {
			continue;
		}
		double x = sqrt(hypoSquared - ySquared);
		// if (transceivers[i].first - x <= covered) {
		// 	covered = max(covered, transceivers[i].first + x);
		// }
		bounds.push_back({ transceivers[i].first - x, transceivers[i].first + x });
	}
	for (int i = 0; i < (int)bounds.size(); i++) {
		if (bounds[i].first <= covered) {
			covered = max(covered, bounds[i].second);
		}
	}

	return covered >= (double)L;
}

int main() {
	ll N, L;
	cin >> N >> L;
	vector<pair<double, double>> transceivers(N);
	for (int i = 0; i < N; i++) cin >> transceivers[i].first >> transceivers[i].second;
	double l = 0;
	double r = 1e9;
	double ans = 0;
	while (r - l >= 0.001) {
		double mid = l + (r - l) / 2;
		// cout << l << ' ' << r << ' ' << mid << '\n';
		if (check(mid, transceivers, N, L)) {
			r = mid;
			ans = mid;
		} else {
			l = mid;
		}
	}
	printf("%0.7lf\n", ans);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 332 KB Output is correct
2 Correct 4 ms 332 KB Output is correct
3 Correct 3 ms 332 KB Output is correct
4 Correct 5 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 604 KB Output is correct
2 Correct 10 ms 572 KB Output is correct
3 Correct 7 ms 576 KB Output is correct
4 Correct 7 ms 572 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 576 KB Output is correct
2 Correct 9 ms 588 KB Output is correct
3 Correct 7 ms 588 KB Output is correct
4 Correct 8 ms 580 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 576 KB Output is correct
2 Correct 10 ms 572 KB Output is correct
3 Correct 7 ms 572 KB Output is correct
4 Correct 8 ms 572 KB Output is correct
5 Correct 8 ms 572 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 149 ms 4764 KB Output is correct
2 Correct 178 ms 4864 KB Output is correct
3 Correct 97 ms 3052 KB Output is correct
4 Correct 115 ms 4744 KB Output is correct
5 Correct 67 ms 2936 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 117 ms 4860 KB Output is correct
2 Correct 105 ms 4632 KB Output is correct
3 Correct 123 ms 4912 KB Output is correct
4 Correct 120 ms 4852 KB Output is correct
5 Correct 130 ms 5064 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 160 ms 5228 KB Output is correct
2 Correct 183 ms 5124 KB Output is correct
3 Correct 135 ms 5032 KB Output is correct
4 Correct 148 ms 5408 KB Output is correct
5 Correct 126 ms 5216 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 216 ms 5572 KB Output is correct
2 Correct 208 ms 5572 KB Output is correct
3 Correct 188 ms 5512 KB Output is correct
4 Correct 151 ms 5468 KB Output is correct
5 Correct 143 ms 5484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 214 ms 5544 KB Output is correct
2 Correct 216 ms 5588 KB Output is correct
3 Correct 173 ms 5524 KB Output is correct
4 Correct 150 ms 5400 KB Output is correct
5 Correct 141 ms 5512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 928 ms 24292 KB Output is correct
2 Execution timed out 1093 ms 24316 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1082 ms 24312 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1088 ms 35908 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1088 ms 35604 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1048 ms 38668 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1085 ms 38672 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1090 ms 41900 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1085 ms 41800 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1091 ms 48148 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1087 ms 15948 KB Time limit exceeded
2 Halted 0 ms 0 KB -