Submission #477071

# Submission time Handle Problem Language Result Execution time Memory
477071 2021-09-30T06:00:43 Z qwerty1234 Mobile (BOI12_mobile) C++14
50 / 100
1000 ms 48004 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;
	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);
		bounds.push_back({ max(transceivers[i].first - x, 0.0), min(transceivers[i].first + x, (double)L) });
	}
	if (bounds.size() == 0) {
		return false;
	}
	double covered = 0;
	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 = 1e18;
	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 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 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 2 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 332 KB Output is correct
2 Correct 5 ms 328 KB Output is correct
3 Correct 4 ms 388 KB Output is correct
4 Correct 6 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 588 KB Output is correct
2 Correct 13 ms 572 KB Output is correct
3 Correct 10 ms 572 KB Output is correct
4 Correct 10 ms 720 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 588 KB Output is correct
2 Correct 12 ms 572 KB Output is correct
3 Correct 10 ms 572 KB Output is correct
4 Correct 11 ms 572 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 588 KB Output is correct
2 Correct 12 ms 596 KB Output is correct
3 Correct 10 ms 588 KB Output is correct
4 Correct 11 ms 572 KB Output is correct
5 Correct 10 ms 572 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 184 ms 4744 KB Output is correct
2 Correct 228 ms 4920 KB Output is correct
3 Correct 147 ms 3080 KB Output is correct
4 Correct 177 ms 4808 KB Output is correct
5 Correct 101 ms 3068 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 186 ms 4916 KB Output is correct
2 Correct 189 ms 4632 KB Output is correct
3 Correct 192 ms 4988 KB Output is correct
4 Correct 178 ms 4928 KB Output is correct
5 Correct 201 ms 5176 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 228 ms 5248 KB Output is correct
2 Correct 238 ms 5080 KB Output is correct
3 Correct 210 ms 5072 KB Output is correct
4 Correct 244 ms 5560 KB Output is correct
5 Correct 202 ms 5376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 320 ms 5584 KB Output is correct
2 Correct 285 ms 5564 KB Output is correct
3 Correct 257 ms 5564 KB Output is correct
4 Correct 235 ms 5544 KB Output is correct
5 Correct 235 ms 5552 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 342 ms 5544 KB Output is correct
2 Correct 318 ms 5512 KB Output is correct
3 Correct 276 ms 5548 KB Output is correct
4 Correct 260 ms 5556 KB Output is correct
5 Correct 227 ms 5556 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1089 ms 24256 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1077 ms 24296 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1075 ms 35548 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1082 ms 35540 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1061 ms 38684 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1097 ms 38752 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1096 ms 41816 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1092 ms 41716 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1048 ms 48004 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1070 ms 15836 KB Time limit exceeded
2 Halted 0 ms 0 KB -