#include <bits/stdc++.h>
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define int long long
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
const int mod = 1e9 + 7;
const int LOG = 20;
const int maxn = 1e5 + 5;
const double eps = 1e-9;
int32_t main() {
ios_base::sync_with_stdio(false);
cout.tie(0); cin.tie(0);
int n, L;
cin >> n >> L;
vector<int> x(n), y(n);
for(int i=0; i<n; i++) cin >> x[i] >> y[i];
double l=1, r=2e9, ans=r;
for(int it=0; it<60; it++) {
double mid = (l + r) / 2.0;
vector<pdd> seg;
for(int i=0; i<n; i++) {
if(abs(y[i]) >= mid) continue;
double len = sqrt(mid * mid - y[i] * y[i]);
double left = x[i] - len, right = x[i] + len;
if( right >= 0 && left <= L ) seg.push_back({ max((double)0, x[i] - len), min((double)L, x[i] + len) });
}
if(seg.size() == 0) {
l = mid;
continue;
}
sort(seg.begin(), seg.end());
bool ok = 1;
double lp=seg[0].first, rp=seg[0].second;
if(lp > 0) ok = 0;
for(int i=1; i<seg.size(); i++) {
if(seg[i].first > rp) ok = 0;
rp = max(rp, seg[i].second);
}
if(ok && rp >= L) ans = min(ans, mid), r = mid;
else l = mid;
}
cout << setprecision(8) << fixed << ans << '\n';
return 0;
}
Compilation message
mobile.cpp: In function 'int32_t main()':
mobile.cpp:55:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<double, double> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
55 | for(int i=1; i<seg.size(); i++) {
| ~^~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
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 |
# |
Verdict |
Execution time |
Memory |
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 |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
604 KB |
Output is correct |
2 |
Correct |
4 ms |
604 KB |
Output is correct |
3 |
Correct |
2 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
756 KB |
Output is correct |
2 |
Correct |
9 ms |
748 KB |
Output is correct |
3 |
Correct |
12 ms |
748 KB |
Output is correct |
4 |
Correct |
4 ms |
748 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
748 KB |
Output is correct |
2 |
Correct |
9 ms |
748 KB |
Output is correct |
3 |
Correct |
13 ms |
748 KB |
Output is correct |
4 |
Correct |
4 ms |
744 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
748 KB |
Output is correct |
2 |
Correct |
9 ms |
748 KB |
Output is correct |
3 |
Correct |
15 ms |
740 KB |
Output is correct |
4 |
Correct |
3 ms |
728 KB |
Output is correct |
5 |
Correct |
5 ms |
748 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
89 ms |
5816 KB |
Output is correct |
2 |
Correct |
263 ms |
4940 KB |
Output is correct |
3 |
Correct |
164 ms |
3228 KB |
Output is correct |
4 |
Correct |
53 ms |
4892 KB |
Output is correct |
5 |
Correct |
53 ms |
3080 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
81 ms |
5044 KB |
Output is correct |
2 |
Correct |
67 ms |
4760 KB |
Output is correct |
3 |
Correct |
67 ms |
5080 KB |
Output is correct |
4 |
Correct |
55 ms |
5036 KB |
Output is correct |
5 |
Correct |
52 ms |
5220 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
232 ms |
5320 KB |
Output is correct |
2 |
Correct |
294 ms |
5120 KB |
Output is correct |
3 |
Correct |
387 ms |
5192 KB |
Output is correct |
4 |
Correct |
46 ms |
5820 KB |
Output is correct |
5 |
Correct |
84 ms |
5348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
296 ms |
5680 KB |
Output is correct |
2 |
Correct |
374 ms |
5680 KB |
Output is correct |
3 |
Correct |
483 ms |
6148 KB |
Output is correct |
4 |
Correct |
47 ms |
5560 KB |
Output is correct |
5 |
Correct |
85 ms |
5668 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
97 ms |
5592 KB |
Output is correct |
2 |
Correct |
380 ms |
5760 KB |
Output is correct |
3 |
Correct |
489 ms |
5664 KB |
Output is correct |
4 |
Correct |
48 ms |
5660 KB |
Output is correct |
5 |
Correct |
93 ms |
5688 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1073 ms |
24328 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1065 ms |
24856 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1034 ms |
36604 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1020 ms |
36732 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1038 ms |
39864 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1004 ms |
39100 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1030 ms |
42668 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1036 ms |
43088 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1026 ms |
48180 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1053 ms |
48192 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |