#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() {
int n, L, mn=1e9;
cin >> n >> L;
vector<int> x(n), y(n);
for(int i=0; i<n; i++) cin >> x[i] >> y[i], mn = min(mn, y[i]);
double l=mn, r=1e10, ans=r;
// double l = 5.545455, r=10, ans=r;
for(int it=0; it<400; it++) {
double mid = (l + r) / 2.0;
vector<pdd> seg;
//cout << mid << '\n';
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) });
//cout << seg.back().first << " " << seg.back().second << '\n';
}
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++) {
| ~^~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 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 |
1 ms |
600 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
344 KB |
Output is correct |
2 |
Correct |
20 ms |
348 KB |
Output is correct |
3 |
Correct |
3 ms |
348 KB |
Output is correct |
4 |
Correct |
10 ms |
568 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
716 KB |
Output is correct |
2 |
Correct |
54 ms |
724 KB |
Output is correct |
3 |
Correct |
58 ms |
716 KB |
Output is correct |
4 |
Correct |
8 ms |
716 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
716 KB |
Output is correct |
2 |
Correct |
54 ms |
716 KB |
Output is correct |
3 |
Correct |
56 ms |
716 KB |
Output is correct |
4 |
Correct |
8 ms |
716 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
22 ms |
716 KB |
Output is correct |
2 |
Correct |
52 ms |
716 KB |
Output is correct |
3 |
Correct |
103 ms |
716 KB |
Output is correct |
4 |
Correct |
8 ms |
732 KB |
Output is correct |
5 |
Correct |
10 ms |
764 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
402 ms |
4856 KB |
Output is correct |
2 |
Execution timed out |
1055 ms |
5216 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
145 ms |
4964 KB |
Output is correct |
2 |
Correct |
153 ms |
4708 KB |
Output is correct |
3 |
Correct |
132 ms |
5036 KB |
Output is correct |
4 |
Correct |
121 ms |
4992 KB |
Output is correct |
5 |
Correct |
124 ms |
5208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1043 ms |
5300 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1047 ms |
5680 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
510 ms |
5616 KB |
Output is correct |
2 |
Execution timed out |
1064 ms |
5652 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1092 ms |
24304 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1032 ms |
24412 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1045 ms |
36180 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1068 ms |
37248 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1032 ms |
42264 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1032 ms |
39068 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1010 ms |
42264 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1046 ms |
43740 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1064 ms |
48544 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1014 ms |
48376 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |