#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<50; 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 |
1 ms |
344 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 |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
600 KB |
Output is correct |
2 |
Correct |
3 ms |
604 KB |
Output is correct |
3 |
Correct |
2 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
600 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
748 KB |
Output is correct |
2 |
Correct |
8 ms |
748 KB |
Output is correct |
3 |
Correct |
13 ms |
748 KB |
Output is correct |
4 |
Correct |
5 ms |
748 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
776 KB |
Output is correct |
2 |
Correct |
10 ms |
748 KB |
Output is correct |
3 |
Correct |
11 ms |
748 KB |
Output is correct |
4 |
Correct |
4 ms |
744 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
744 KB |
Output is correct |
2 |
Correct |
13 ms |
744 KB |
Output is correct |
3 |
Correct |
13 ms |
744 KB |
Output is correct |
4 |
Correct |
4 ms |
732 KB |
Output is correct |
5 |
Correct |
5 ms |
748 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
88 ms |
4880 KB |
Output is correct |
2 |
Correct |
221 ms |
4976 KB |
Output is correct |
3 |
Correct |
132 ms |
3196 KB |
Output is correct |
4 |
Correct |
66 ms |
4920 KB |
Output is correct |
5 |
Correct |
51 ms |
3088 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
82 ms |
5012 KB |
Output is correct |
2 |
Correct |
65 ms |
4744 KB |
Output is correct |
3 |
Correct |
70 ms |
5120 KB |
Output is correct |
4 |
Correct |
60 ms |
4988 KB |
Output is correct |
5 |
Correct |
55 ms |
5212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
203 ms |
5324 KB |
Output is correct |
2 |
Correct |
265 ms |
5152 KB |
Output is correct |
3 |
Correct |
315 ms |
5220 KB |
Output is correct |
4 |
Correct |
44 ms |
5564 KB |
Output is correct |
5 |
Correct |
90 ms |
5348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
243 ms |
5684 KB |
Output is correct |
2 |
Correct |
313 ms |
5680 KB |
Output is correct |
3 |
Correct |
405 ms |
5700 KB |
Output is correct |
4 |
Correct |
44 ms |
5552 KB |
Output is correct |
5 |
Correct |
80 ms |
5680 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
86 ms |
5660 KB |
Output is correct |
2 |
Correct |
305 ms |
5672 KB |
Output is correct |
3 |
Correct |
402 ms |
5676 KB |
Output is correct |
4 |
Correct |
52 ms |
5592 KB |
Output is correct |
5 |
Correct |
75 ms |
6216 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1061 ms |
24484 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1024 ms |
24464 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1037 ms |
36660 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1064 ms |
35924 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1062 ms |
38812 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1014 ms |
39256 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1016 ms |
43392 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1062 ms |
43032 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1028 ms |
48192 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1065 ms |
49056 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |