답안 #477077

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
477077 2021-09-30T06:10:01 Z qwerty1234 Mobile (BOI12_mobile) C++17
70 / 100
1000 ms 16452 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({ max(transceivers[i].first - x, 0.0), min(transceivers[i].first + x, (double)L) });
	}
	// if (bounds.size() == 0) {
	// 	return false;
	// }
	// for (int i = 0; i < (int)bounds.size(); i++) {
	// 	if (bounds[i].first <= covered) {
	// 		covered = max(covered, bounds[i].second);
	// 	}
	// }

	return covered >= 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);
}
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 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 4 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 344 KB Output is correct
2 Correct 7 ms 432 KB Output is correct
3 Correct 5 ms 332 KB Output is correct
4 Correct 7 ms 440 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 332 KB Output is correct
2 Correct 7 ms 432 KB Output is correct
3 Correct 6 ms 332 KB Output is correct
4 Correct 7 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 420 KB Output is correct
2 Correct 9 ms 332 KB Output is correct
3 Correct 5 ms 332 KB Output is correct
4 Correct 8 ms 332 KB Output is correct
5 Correct 8 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 85 ms 1588 KB Output is correct
2 Correct 98 ms 1604 KB Output is correct
3 Correct 61 ms 1228 KB Output is correct
4 Correct 103 ms 1556 KB Output is correct
5 Correct 44 ms 1128 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 84 ms 1612 KB Output is correct
2 Correct 77 ms 1508 KB Output is correct
3 Correct 118 ms 1676 KB Output is correct
4 Correct 119 ms 1612 KB Output is correct
5 Correct 116 ms 1768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 82 ms 1740 KB Output is correct
2 Correct 104 ms 1700 KB Output is correct
3 Correct 102 ms 1740 KB Output is correct
4 Correct 152 ms 1988 KB Output is correct
5 Correct 94 ms 1808 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 138 ms 1984 KB Output is correct
2 Correct 124 ms 1868 KB Output is correct
3 Correct 126 ms 1988 KB Output is correct
4 Correct 155 ms 1868 KB Output is correct
5 Correct 115 ms 1972 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 134 ms 1972 KB Output is correct
2 Correct 128 ms 1972 KB Output is correct
3 Correct 107 ms 1980 KB Output is correct
4 Correct 147 ms 1972 KB Output is correct
5 Correct 114 ms 1868 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 503 ms 8244 KB Output is correct
2 Correct 666 ms 8256 KB Output is correct
3 Correct 626 ms 8236 KB Output is correct
4 Correct 742 ms 8240 KB Output is correct
5 Correct 615 ms 8140 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 695 ms 8236 KB Output is correct
2 Correct 666 ms 8240 KB Output is correct
3 Correct 564 ms 8244 KB Output is correct
4 Correct 712 ms 8244 KB Output is correct
5 Correct 631 ms 8236 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 662 ms 9808 KB Output is correct
2 Correct 796 ms 9804 KB Output is correct
3 Correct 767 ms 9804 KB Output is correct
4 Correct 900 ms 9804 KB Output is correct
5 Correct 723 ms 9804 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 840 ms 9804 KB Output is correct
2 Correct 816 ms 9804 KB Output is correct
3 Correct 684 ms 9804 KB Output is correct
4 Correct 915 ms 9804 KB Output is correct
5 Correct 748 ms 9804 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 679 ms 11340 KB Output is correct
2 Correct 932 ms 11368 KB Output is correct
3 Correct 899 ms 11588 KB Output is correct
4 Execution timed out 1042 ms 11500 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 948 ms 11368 KB Output is correct
2 Correct 924 ms 11560 KB Output is correct
3 Correct 785 ms 11408 KB Output is correct
4 Execution timed out 1010 ms 11516 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 795 ms 12940 KB Output is correct
2 Execution timed out 1059 ms 13004 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1082 ms 12940 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 993 ms 16076 KB Output is correct
2 Execution timed out 1097 ms 16196 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1079 ms 16452 KB Time limit exceeded
2 Halted 0 ms 0 KB -