#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T1, typename T2>
using indexed_map = tree<T1, T2, less<T1>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using indexed_set = indexed_map<T, null_type>;
#define loop(x, i) for (int i = 0; i < (x); i++)
#define loop1(x, i) for (int i = 1; i <= (x); i++)
#define rev(x, i) for (int i = (int)(x) - 1; i >= 0; i--)
#define itloop(x) for (auto it = begin(x); x != end(x); it++)
#define itrev(x) for (auto it = rbegin(x); x != rend(x); it++)
// #define int long long
#define INF ((int64_t)(4e18 + 1))
#define INF32 ((int32_t)(2e9 + 1))
#define ALL(x) begin(x), end(x)
#define RALL(x) rbegin(x), rend(x)
#define existsIn(x, l) (count(ALL(l), x) > 0)
#define removeIn(x, l) l.erase(find(ALL(l), x))
#define pb push_back
#define sz(x) (int)(x).size()
#define x first
#define y second
#define var const auto &
#define foreach(l) for (var e : l)
typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vii> vvii;
typedef vector<viii> vviii;
typedef set<int> si;
typedef set<ii> sii;
typedef set<iii> siii;
typedef vector<si> vsi;
typedef vector<sii> vsii;
typedef vector<vsi> vvsi;
typedef vector<string> vstr;
typedef vector<vector<string>> vvstr;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vi::iterator viit;
typedef si::iterator siit;
typedef int8_t in8;
typedef int16_t in16;
typedef int32_t in32;
typedef int64_t in64;
typedef long double ld;
typedef vector<pair<ld, ld>> vff;
// ld eps = 4e-4; // 13pt
ld eps = 5e-4; // 13pt
// ld eps = 1e-18; // 4pt: TLE
void solve()
{
int N;
ld L;
cin >> N >> L;
vii points;
loop(N, i)
{
int x, y;
cin >> x >> y;
if (!points.empty() && points.back().x == x)
{
points.back().y = min(abs(y), abs(points.back().y));
}
else
points.pb({x, y});
}
N = points.size();
vff a;
for (var[x, y] : points)
a.pb({x, y});
/*vff a(N);
loop(N, i)
{
cin >> a[i].x >> a[i].y;
}*/
ld lo = 0.0L, hi = sqrt(1e18L + L * L);
while (hi - lo > eps)
{
ld R = lo + (hi - lo) / 2.0L;
vff segments;
loop(N, i)
{
auto [x, y] = a[i];
ld D = (R * R) - ((ld)y * (ld)y);
if (D >= 0.0L)
{
ld l = x - sqrt(D);
ld r = x + sqrt(D);
l = max(l, 0.0L);
r = min(r, L);
if (l > r)
continue;
while (!segments.empty() && segments.back().x > l)
{
segments.pop_back();
}
segments.pb({l, r});
}
}
if (segments.empty())
{
lo = R;
continue;
}
// sort(ALL(segments));
bool highwayCovered = 1;
ld l = segments[0].first, r = segments[0].second;
if (l > 0)
highwayCovered = 0;
else
{
for (auto [l_i, r_i] : segments)
{
if (l_i > r)
{
highwayCovered = 0;
break;
}
r = max(r, r_i);
}
}
if (r < L)
highwayCovered = 0;
if (highwayCovered)
{
hi = R;
}
else
lo = R;
}
ld res = lo + (hi - lo) / 2.0L;
cout << fixed << setprecision(4) << res << endl;
}
signed main()
{
cin.tie(0)->sync_with_stdio(0);
solve();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
600 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
3 ms |
780 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
3 ms |
600 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
604 KB |
Output is correct |
2 |
Correct |
9 ms |
1204 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
4 ms |
1084 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
764 KB |
Output is correct |
2 |
Correct |
8 ms |
1080 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
4 ms |
1084 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
1124 KB |
Output is correct |
2 |
Correct |
8 ms |
1080 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
4 ms |
1112 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
80 ms |
9720 KB |
Output is correct |
2 |
Correct |
71 ms |
6484 KB |
Output is correct |
3 |
Correct |
82 ms |
6368 KB |
Output is correct |
4 |
Correct |
55 ms |
10812 KB |
Output is correct |
5 |
Correct |
5 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
1040 KB |
Output is correct |
2 |
Correct |
40 ms |
5072 KB |
Output is correct |
3 |
Correct |
73 ms |
10956 KB |
Output is correct |
4 |
Correct |
60 ms |
10056 KB |
Output is correct |
5 |
Correct |
55 ms |
11172 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
171 ms |
10940 KB |
Output is correct |
2 |
Correct |
66 ms |
6236 KB |
Output is correct |
3 |
Correct |
97 ms |
9908 KB |
Output is correct |
4 |
Correct |
45 ms |
10932 KB |
Output is correct |
5 |
Correct |
29 ms |
2724 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
60 ms |
5532 KB |
Output is correct |
2 |
Correct |
58 ms |
5532 KB |
Output is correct |
3 |
Correct |
22 ms |
2040 KB |
Output is correct |
4 |
Correct |
51 ms |
10896 KB |
Output is correct |
5 |
Correct |
76 ms |
10568 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
91 ms |
11528 KB |
Output is correct |
2 |
Correct |
63 ms |
5568 KB |
Output is correct |
3 |
Correct |
22 ms |
1848 KB |
Output is correct |
4 |
Correct |
62 ms |
11136 KB |
Output is correct |
5 |
Correct |
76 ms |
10676 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
984 ms |
52444 KB |
Output is correct |
2 |
Correct |
61 ms |
1484 KB |
Output is correct |
3 |
Correct |
59 ms |
1480 KB |
Output is correct |
4 |
Correct |
226 ms |
51940 KB |
Output is correct |
5 |
Correct |
322 ms |
39796 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
63 ms |
1484 KB |
Output is correct |
2 |
Correct |
525 ms |
51812 KB |
Output is correct |
3 |
Correct |
155 ms |
12044 KB |
Output is correct |
4 |
Correct |
250 ms |
52132 KB |
Output is correct |
5 |
Correct |
337 ms |
48908 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1067 ms |
75372 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
74 ms |
1216 KB |
Output is correct |
2 |
Correct |
589 ms |
74640 KB |
Output is correct |
3 |
Correct |
132 ms |
10764 KB |
Output is correct |
4 |
Correct |
372 ms |
74760 KB |
Output is correct |
5 |
Correct |
442 ms |
70588 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1063 ms |
77152 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
92 ms |
1144 KB |
Output is correct |
2 |
Correct |
711 ms |
78724 KB |
Output is correct |
3 |
Correct |
193 ms |
13564 KB |
Output is correct |
4 |
Correct |
330 ms |
78812 KB |
Output is correct |
5 |
Correct |
496 ms |
74500 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1037 ms |
81356 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
116 ms |
1088 KB |
Output is correct |
2 |
Correct |
818 ms |
82544 KB |
Output is correct |
3 |
Correct |
203 ms |
13216 KB |
Output is correct |
4 |
Correct |
363 ms |
81388 KB |
Output is correct |
5 |
Correct |
555 ms |
77772 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1097 ms |
89388 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
114 ms |
1164 KB |
Output is correct |
2 |
Correct |
985 ms |
88064 KB |
Output is correct |
3 |
Correct |
270 ms |
19604 KB |
Output is correct |
4 |
Correct |
482 ms |
88716 KB |
Output is correct |
5 |
Correct |
675 ms |
82588 KB |
Output is correct |