#pragma GCC optimize ("Ofast,fast-math")
#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
inline bool a_contains_b(array<ld, 2> a, array<ld, 2> b) {
return a[0] <= b[0] && b[1] <= a[1];
}
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
array<ld, 2> new_interval{x[i] - dx, x[i] + dx};
while (!intervals.empty() && a_contains_b(new_interval, intervals.back())) {
intervals.pop_back();
}
if (!(!intervals.empty() && a_contains_b(intervals.back(), new_interval)))
intervals.pb({x[i] - dx, x[i] + dx});
}
// merge intervals
vector<array<ld, 2>> merged;
merged.reserve(n);
for (auto [s, e] : intervals) {
if (!merged.empty() && s <= merged.back()[1]) smax(merged.back()[1], e);
else merged.pb({s, e});
}
// check interval spans whole highway
return any_of(all(merged), [&](array<ld, 2> interval) -> bool {return a_contains_b(interval, {0, (ld) l});});
}, 0, sqrt(1e18 + 4 * 1e18 + 1e10)) << '\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 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 |
Correct |
2 ms |
364 KB |
Output is correct |
2 |
Correct |
4 ms |
432 KB |
Output is correct |
3 |
Correct |
2 ms |
332 KB |
Output is correct |
4 |
Correct |
5 ms |
424 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
472 KB |
Output is correct |
2 |
Correct |
8 ms |
552 KB |
Output is correct |
3 |
Correct |
3 ms |
416 KB |
Output is correct |
4 |
Correct |
4 ms |
532 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
492 KB |
Output is correct |
2 |
Correct |
8 ms |
552 KB |
Output is correct |
3 |
Correct |
3 ms |
424 KB |
Output is correct |
4 |
Correct |
5 ms |
532 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
556 KB |
Output is correct |
2 |
Correct |
9 ms |
552 KB |
Output is correct |
3 |
Correct |
4 ms |
444 KB |
Output is correct |
4 |
Correct |
4 ms |
560 KB |
Output is correct |
5 |
Correct |
5 ms |
420 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
101 ms |
3692 KB |
Output is correct |
2 |
Correct |
74 ms |
3200 KB |
Output is correct |
3 |
Correct |
76 ms |
2864 KB |
Output is correct |
4 |
Correct |
35 ms |
2152 KB |
Output is correct |
5 |
Correct |
29 ms |
1240 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
44 ms |
2000 KB |
Output is correct |
2 |
Correct |
48 ms |
2516 KB |
Output is correct |
3 |
Correct |
47 ms |
3268 KB |
Output is correct |
4 |
Correct |
41 ms |
2252 KB |
Output is correct |
5 |
Correct |
35 ms |
2148 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
154 ms |
4556 KB |
Output is correct |
2 |
Correct |
75 ms |
3152 KB |
Output is correct |
3 |
Correct |
107 ms |
3940 KB |
Output is correct |
4 |
Correct |
38 ms |
2300 KB |
Output is correct |
5 |
Correct |
59 ms |
2256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
113 ms |
3068 KB |
Output is correct |
2 |
Correct |
97 ms |
3144 KB |
Output is correct |
3 |
Correct |
69 ms |
2532 KB |
Output is correct |
4 |
Correct |
39 ms |
2316 KB |
Output is correct |
5 |
Correct |
59 ms |
3940 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
188 ms |
5044 KB |
Output is correct |
2 |
Correct |
83 ms |
3172 KB |
Output is correct |
3 |
Correct |
65 ms |
2484 KB |
Output is correct |
4 |
Correct |
38 ms |
2352 KB |
Output is correct |
5 |
Correct |
58 ms |
3788 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
936 ms |
24112 KB |
Output is correct |
2 |
Correct |
299 ms |
16152 KB |
Output is correct |
3 |
Correct |
337 ms |
15664 KB |
Output is correct |
4 |
Correct |
184 ms |
18148 KB |
Output is correct |
5 |
Correct |
258 ms |
19520 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
314 ms |
8464 KB |
Output is correct |
2 |
Correct |
720 ms |
23680 KB |
Output is correct |
3 |
Correct |
323 ms |
11164 KB |
Output is correct |
4 |
Correct |
179 ms |
8648 KB |
Output is correct |
5 |
Correct |
213 ms |
11076 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1086 ms |
28816 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
357 ms |
9960 KB |
Output is correct |
2 |
Correct |
869 ms |
28296 KB |
Output is correct |
3 |
Correct |
360 ms |
18728 KB |
Output is correct |
4 |
Correct |
220 ms |
21868 KB |
Output is correct |
5 |
Correct |
286 ms |
21708 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1086 ms |
33476 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
439 ms |
11496 KB |
Output is correct |
2 |
Correct |
986 ms |
32892 KB |
Output is correct |
3 |
Correct |
470 ms |
23796 KB |
Output is correct |
4 |
Correct |
271 ms |
25212 KB |
Output is correct |
5 |
Correct |
299 ms |
25084 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1091 ms |
38136 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
477 ms |
13204 KB |
Output is correct |
2 |
Execution timed out |
1082 ms |
37592 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1090 ms |
47496 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
644 ms |
16260 KB |
Output is correct |
2 |
Execution timed out |
1099 ms |
46728 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |