#include<bits/stdc++.h>
#define unless(x) if (!(x))
#define pb push_back
#define eb emplace_back
/* #define f first */
/* #define s second */
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define mem(x, y) memset(x, y, sizeof(x))
#define sz(x) ((int) (x).size())
#define popcnt __builtin_popcntll
using namespace std;
using ll = long long;
using ld = long double;
using pi = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vpi = vector<pi>;
using vpll = vector<pll>;
using vvi = vector<vector<int>>;
// *INDENT-OFF*
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template<typename T, typename V> void __print(const pair<T, V> &x) { cerr << '{'; __print(x.first); cerr << ", "; __print(x.second); cerr << '}'; }
template<size_t I = 0, typename... Tp> void __print_tup(const tuple<Tp...>& t) { cerr << get<I>(t); if constexpr(I < sizeof...(Tp) - 1) { cerr << ", "; __print_tup<I+1>(t); } }
template<typename... Tp> void __print(const tuple<Tp...>& t) { cerr << '{'; __print_tup(t); cerr << '}'; }
/* template<typename... Args> void __print(const tuple<Args...>& t) { cerr << '{'; apply([](auto&&... args) { ((cout << args << ','), ...); }, t); cerr << '}'; } */
template<typename T> void __print(const T &x) { int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? ", " : ""), __print(i); cerr << "}"; }
void _print() { cerr << "]\n"; }
template <typename T, typename... V> void _print(T t, V... v) { __print(t); if (sizeof...(v)) cerr << ", "; _print(v...); }
template<typename T> T fdiv(T x, T y) { T q = x / y; T r = x % y; if ((r != 0) && ((r < 0) != (y < 0))) --q; return q; }
template<typename T> T cdiv(T x, T y) { return x / y + ((x % y != 0) ? !((x > 0) ^ (y > 0)) : 0); }
namespace std { template<class Fun> class y_combinator_result { Fun fun_; public: template<class T> explicit y_combinator_result(T &&fun): fun_(std::forward<T>(fun)) {} template<class ...Args> decltype(auto) operator()(Args &&...args) { return fun_(std::ref(*this), std::forward<Args>(args)...); } }; template<class Fun> decltype(auto) yy(Fun &&fun) { return y_combinator_result<std::decay_t<Fun>>(std::forward<Fun>(fun)); } }
const string yes = "Yes";
const string no = "No";
const int infs = 0x3f;
const int infb = 0x3f3f3f3f;
#ifdef LOCAL
#define dbg(x...) cerr << "\e[1;31m"<<__func__<<":"<<__LINE__<<" [" << #x << "] = ["; _print(x); cerr << "\e[0m";
#else
#define dbg(x...)
#endif
// *INDENT-ON*
// YOU ARE ACTUALLY **SUPPOSED** TO READ THE FOLLOWING.
// Read the problem. Now Re-read the problem.
// Observe each constraint. Please do this. Notice each and every constraint.
// You have made many mistakes because you didn't read the constraint well enough.
// You are probably solving a harder version of the given problem.
// DO NOT OVERSOLVE.
// Do not look ahead for next problem. Solve the current problem.
// Do not look at standings.
// check overflow/underflow
// Declare double values as long double or ld (NEVER double, because of precision issues)
// Open the damn Excel Sheet!!!!
// BE EXTRA EXTRA EXTRA CAREFUL WHILE MULTIPLYING!!!!! <- SEE THIS!!! SEE THIS!!!
void solve() {
int n, l;
cin >> n >> l;
vpll v(n);
for (auto &[a, b] : v) {
cin >> a >> b;
}
ld epsilon = 1.0L / 1e9;
ld lo = 0, hi = 4e9;
while (hi - lo > epsilon) {
ld mid = (lo + hi) / 2;
int flg = 0;
ld left = 2e9, right = -2e9;
for (auto [a, b] : v) {
ld D = mid * mid - b * b;
if (D >= 0) {
ld lefti = a - sqrt(D);
ld righti = a + sqrt(D);
if (flg == 0) {
flg = 1;
left = lefti;
right = righti;
} else {
if (max(left, lefti) <= min(right, righti)) {
ckmin(left, lefti);
ckmax(right, righti);
}
}
}
}
if (left <= 0 && right >= l) {
hi = mid;
} else {
lo = mid;
}
}
cout << fixed << setprecision(6) << lo << '\n';
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int t = 1;
/* cin >> t; */
while (t--) {
solve();
}
return 0;
}
Compilation message
mobile.cpp: In function 'void __print_tup(const std::tuple<_Elements ...>&)':
mobile.cpp:45:104: warning: 'if constexpr' only available with '-std=c++17' or '-std=gnu++17'
45 | template<size_t I = 0, typename... Tp> void __print_tup(const tuple<Tp...>& t) { cerr << get<I>(t); if constexpr(I < sizeof...(Tp) - 1) { cerr << ", "; __print_tup<I+1>(t); } }
| ^~~~~~~~~
mobile.cpp: In function 'void solve()':
mobile.cpp:83:16: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
83 | for (auto &[a, b] : v) {
| ^
mobile.cpp:92:19: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
92 | for (auto [a, b] : v) {
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
340 KB |
Output is correct |
2 |
Correct |
3 ms |
340 KB |
Output is correct |
3 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
340 KB |
Output is correct |
2 |
Correct |
4 ms |
340 KB |
Output is correct |
3 |
Correct |
4 ms |
332 KB |
Output is correct |
4 |
Correct |
3 ms |
460 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
340 KB |
Output is correct |
2 |
Correct |
6 ms |
468 KB |
Output is correct |
3 |
Correct |
3 ms |
340 KB |
Output is correct |
4 |
Correct |
3 ms |
476 KB |
Output is correct |
5 |
Correct |
3 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
64 ms |
1492 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
33 ms |
1492 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
65 ms |
1620 KB |
Output is correct |
2 |
Correct |
66 ms |
2736 KB |
Output is correct |
3 |
Correct |
58 ms |
2540 KB |
Output is correct |
4 |
Incorrect |
36 ms |
3788 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
74 ms |
1876 KB |
Output is correct |
2 |
Correct |
83 ms |
3280 KB |
Output is correct |
3 |
Correct |
67 ms |
3012 KB |
Output is correct |
4 |
Correct |
37 ms |
3784 KB |
Output is correct |
5 |
Incorrect |
40 ms |
3036 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
75 ms |
1876 KB |
Output is correct |
2 |
Correct |
89 ms |
1876 KB |
Output is correct |
3 |
Correct |
68 ms |
2908 KB |
Output is correct |
4 |
Correct |
38 ms |
3784 KB |
Output is correct |
5 |
Incorrect |
40 ms |
3156 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
352 ms |
8152 KB |
Output is correct |
2 |
Correct |
384 ms |
15804 KB |
Output is correct |
3 |
Correct |
385 ms |
15292 KB |
Output is correct |
4 |
Incorrect |
181 ms |
17596 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
394 ms |
8148 KB |
Output is correct |
2 |
Incorrect |
431 ms |
14648 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
416 ms |
9684 KB |
Output is correct |
2 |
Correct |
466 ms |
19020 KB |
Output is correct |
3 |
Correct |
450 ms |
18272 KB |
Output is correct |
4 |
Correct |
217 ms |
21464 KB |
Output is correct |
5 |
Correct |
238 ms |
17640 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
463 ms |
9684 KB |
Output is correct |
2 |
Correct |
484 ms |
17492 KB |
Output is correct |
3 |
Correct |
398 ms |
16488 KB |
Output is correct |
4 |
Incorrect |
210 ms |
21336 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
504 ms |
11220 KB |
Output is correct |
2 |
Correct |
523 ms |
22028 KB |
Output is correct |
3 |
Correct |
526 ms |
21368 KB |
Output is correct |
4 |
Incorrect |
265 ms |
24704 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
530 ms |
11248 KB |
Output is correct |
2 |
Correct |
548 ms |
20476 KB |
Output is correct |
3 |
Correct |
458 ms |
19576 KB |
Output is correct |
4 |
Correct |
287 ms |
24584 KB |
Output is correct |
5 |
Correct |
282 ms |
21448 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
563 ms |
12756 KB |
Output is correct |
2 |
Correct |
616 ms |
25108 KB |
Output is correct |
3 |
Correct |
661 ms |
24340 KB |
Output is correct |
4 |
Correct |
288 ms |
28436 KB |
Output is correct |
5 |
Incorrect |
327 ms |
23972 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
592 ms |
12756 KB |
Output is correct |
2 |
Incorrect |
681 ms |
23372 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
705 ms |
15956 KB |
Output is correct |
2 |
Correct |
791 ms |
31444 KB |
Output is correct |
3 |
Correct |
782 ms |
30416 KB |
Output is correct |
4 |
Correct |
390 ms |
35148 KB |
Output is correct |
5 |
Correct |
404 ms |
29516 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
792 ms |
15956 KB |
Output is correct |
2 |
Correct |
784 ms |
29148 KB |
Output is correct |
3 |
Correct |
648 ms |
28236 KB |
Output is correct |
4 |
Correct |
403 ms |
35288 KB |
Output is correct |
5 |
Incorrect |
422 ms |
30676 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |