Submission #477068

# Submission time Handle Problem Language Result Execution time Memory
477068 2021-09-30T05:51:10 Z qwerty1234 Mobile (BOI12_mobile) C++17
0 / 100
1000 ms 48008 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 = bounds[0].second - bounds[0].first;
	double right = bounds[0].second;
	for (int i = 1; i < (int)bounds.size(); i++) {
		double currBound = bounds[i].second - bounds[i].first;
		currBound -= max(0.0, right - bounds[i].first);
		covered += max(0.0, currBound);
		right = max(bounds[i].second, right);
	}

	return abs(covered - (double)L) <= 0.000001;
}

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.0001) {
		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 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 436 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 576 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 580 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 572 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 236 ms 4796 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 251 ms 4876 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 259 ms 5212 KB Output is correct
2 Incorrect 245 ms 6180 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 311 ms 5572 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 316 ms 5620 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1088 ms 24244 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1086 ms 24264 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1087 ms 35664 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1095 ms 35528 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1093 ms 38760 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1084 ms 38660 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1090 ms 41816 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1093 ms 41804 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1092 ms 48008 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1091 ms 15948 KB Time limit exceeded
2 Halted 0 ms 0 KB -