Submission #88187

# Submission time Handle Problem Language Result Execution time Memory
88187 2018-12-04T10:11:02 Z JustInCase Mobile (BOI12_mobile) C++17
25 / 100
1000 ms 71208 KB
#include <bits/stdc++.h>

const int32_t MAX_N = 1e6;
const double EPS = 1e-6;

int32_t n, l;
std::pair< int32_t, int32_t > points[MAX_N + 5];

bool Check(long double r) {
	std::vector< std::pair< long double, bool > > events(2 * n);

	for(int32_t i = 0; i < n; i++) {
		if(r * r < (int64_t) points[i].second * points[i].second) {
			events[2 * i] = { -2.0, 0 };
			events[2 * i + 1] = { -1.0, 1 };
			continue;
		}

		long double x1 = points[i].first - sqrt(r * r - (int64_t) points[i].second * points[i].second);
		long double x2 = points[i].first + sqrt(r * r - (int64_t) points[i].second * points[i].second);

		events[2 * i] = { x1, 0 };
		events[2 * i + 1] = { x2, 1 };
	}

	std::sort(events.begin(), events.end());

	int32_t currCnt = 0;
	for(int32_t i = 0; i < 2 * n; i++) {
		if(events[i].first > 0 && currCnt == 0) {
			return false;
		}

		if(events[i].first > l) {
			break;
		}

		if(events[i].second == 0) {
			currCnt++;
		}
		else {
			currCnt--;
		}

		if(!(events[i].first < 0.0) && currCnt == 0) {
			return false;
		}
	}

	if(events.back().first < 0) {
		return false;
	}

	return true;
}

int main() {
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(nullptr);

	std::cin >> n >> l;

	for(int32_t i = 0; i < n; i++) {
		std::cin >> points[i].first >> points[i].second;
	}

	int64_t low = 1, high = 1e16;
	long double ans;
	while(low <= high) {
		int64_t mid = (low + high) / 2;

		if(Check(mid / 1000.0)) {
			ans = mid / 1000.0;
			high = mid - 1;
		}
		else {
			low = mid + 1;
		}
	}

	std::cout << std::fixed << std::setprecision(7);
	std::cout << ans << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 552 KB Output is correct
4 Correct 2 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 600 KB Output is correct
2 Correct 3 ms 600 KB Output is correct
3 Correct 3 ms 600 KB Output is correct
4 Correct 3 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 29 ms 780 KB Output is correct
2 Correct 26 ms 1028 KB Output is correct
3 Correct 22 ms 1028 KB Output is correct
4 Correct 23 ms 1028 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 58 ms 1028 KB Output is correct
2 Correct 53 ms 1028 KB Output is correct
3 Correct 56 ms 1028 KB Output is correct
4 Correct 55 ms 1028 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 53 ms 1028 KB Output is correct
2 Correct 54 ms 1028 KB Output is correct
3 Correct 54 ms 1028 KB Output is correct
4 Correct 54 ms 1028 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 59 ms 1028 KB Output is correct
2 Correct 53 ms 1056 KB Output is correct
3 Correct 54 ms 1056 KB Output is correct
4 Correct 53 ms 1128 KB Output is correct
5 Correct 54 ms 1128 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 968 ms 5912 KB Output is correct
2 Execution timed out 1060 ms 5996 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1020 ms 6212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1045 ms 6764 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1078 ms 7660 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1065 ms 7660 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1040 ms 35884 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1028 ms 35892 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1062 ms 42940 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1039 ms 43020 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1008 ms 49996 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1006 ms 50092 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1025 ms 57088 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1076 ms 57088 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1030 ms 71208 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1035 ms 71208 KB Time limit exceeded
2 Halted 0 ms 0 KB -