#pragma GCC optimize ("O3,fast-math,inline")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename K> using hset = gp_hash_table<K, null_type>;
template <typename K, typename V> using hmap = gp_hash_table<K, V>;
using namespace std;
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define smax(x, y) (x = max(x, y))
#define smin(x, y) (x = min(x, y))
using ld = long double;
using ll = long long;
template <typename T>
using vv = vector<vector<T>>;
using vi = vector<int>;
using ii = array<int, 2>;
using vii = vector<ii>;
using vvi = vv<int>;
using vll = vector<ll>;
using l2 = array<int, 2>;
using vl2 = vector<l2>;
using vvll = vv<ll>;
template <typename T>
using minq = priority_queue<T, vector<T>, greater<T>>;
template <typename T>
using maxq = priority_queue<T>;
const ll M = 1000000007;
#ifndef REFERENCE_DISCRETE_BINARY_SEARCH_H
#define REFERENCE_DISCRETE_BINARY_SEARCH_H
#include <iostream>
#include <functional>
template<typename IN>
IN discrete_binary_search(function<bool(IN)> predicate, IN low = 0, IN high = numeric_limits<IN>::max()) {
while (fabs(high - low) > 1e-4) {
IN middle = low + (high - low) / 2; // todo std::midpoint in cpp 2020
if (predicate(middle))
high = middle;
else low = middle;
}
return low;
}
#endif //REFERENCE_DISCRETE_BINARY_SEARCH_H
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n, l;
cin >> n >> l;
vll x(n), y(n);
for (int i = 0; i < n; ++i) {
cin >> x[i] >> y[i];
}
cout << fixed << setprecision(4) << discrete_binary_search<ld>([&](ld d) -> bool {
// is there a point with min distance > d
// equivalently, is every point within distance d
vector<array<ld, 2>> intervals;
intervals.reserve(n);
// add to intervals
for (int i = 0; i < n; ++i) {
if (abs(y[i]) > d) continue;
ld dx = sqrt(d * d - y[i] * y[i]);
// get rid of nested intervals
ld s1 = x[i] - dx, e1 = x[i] + dx;
// can merge in place
if (!intervals.empty()) {
auto & [s2, e2] = intervals.back();
if (max(s1, s2) <= min(e1, e2)){
smin(s2, s1);
smax(e2, e1);
} else {
intervals.pb({s1, e1});
}
} else {
intervals.pb({s1, e1});
}
}
// check interval spans whole highway
for (auto [s, e] : intervals) {
if (s <= 0 && l <= e) return true;
}
return false;
}, 0, sqrt(1e18 + 4 * 1e18 + 1e10)) << '\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
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 |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
332 KB |
Output is correct |
2 |
Correct |
6 ms |
332 KB |
Output is correct |
3 |
Correct |
5 ms |
332 KB |
Output is correct |
4 |
Correct |
3 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
69 ms |
1504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
53 ms |
1552 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
92 ms |
1808 KB |
Output is correct |
2 |
Correct |
92 ms |
1616 KB |
Output is correct |
3 |
Correct |
78 ms |
1636 KB |
Output is correct |
4 |
Correct |
56 ms |
1872 KB |
Output is correct |
5 |
Incorrect |
57 ms |
1716 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
113 ms |
1896 KB |
Output is correct |
2 |
Correct |
104 ms |
1884 KB |
Output is correct |
3 |
Correct |
89 ms |
1900 KB |
Output is correct |
4 |
Incorrect |
40 ms |
1912 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
103 ms |
1892 KB |
Output is correct |
2 |
Correct |
103 ms |
2000 KB |
Output is correct |
3 |
Correct |
91 ms |
1868 KB |
Output is correct |
4 |
Incorrect |
52 ms |
1884 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
499 ms |
8264 KB |
Output is correct |
2 |
Correct |
535 ms |
8252 KB |
Output is correct |
3 |
Correct |
513 ms |
8260 KB |
Output is correct |
4 |
Incorrect |
226 ms |
8144 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
520 ms |
8252 KB |
Output is correct |
2 |
Incorrect |
487 ms |
8548 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
597 ms |
9708 KB |
Output is correct |
2 |
Correct |
617 ms |
9708 KB |
Output is correct |
3 |
Correct |
616 ms |
9828 KB |
Output is correct |
4 |
Incorrect |
251 ms |
9708 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
672 ms |
9708 KB |
Output is correct |
2 |
Incorrect |
565 ms |
10076 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
702 ms |
11280 KB |
Output is correct |
2 |
Correct |
712 ms |
11280 KB |
Output is correct |
3 |
Correct |
724 ms |
11280 KB |
Output is correct |
4 |
Incorrect |
291 ms |
11276 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
759 ms |
11284 KB |
Output is correct |
2 |
Incorrect |
650 ms |
11656 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
793 ms |
12836 KB |
Output is correct |
2 |
Correct |
823 ms |
12844 KB |
Output is correct |
3 |
Correct |
828 ms |
12840 KB |
Output is correct |
4 |
Incorrect |
315 ms |
12836 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
846 ms |
12840 KB |
Output is correct |
2 |
Incorrect |
734 ms |
13096 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
999 ms |
15976 KB |
Output is correct |
2 |
Execution timed out |
1025 ms |
16020 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1073 ms |
15968 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |