#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<350; 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 |
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 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 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 |
4 ms |
348 KB |
Output is correct |
2 |
Correct |
18 ms |
580 KB |
Output is correct |
3 |
Correct |
3 ms |
348 KB |
Output is correct |
4 |
Correct |
9 ms |
468 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
968 KB |
Output is correct |
2 |
Correct |
50 ms |
728 KB |
Output is correct |
3 |
Correct |
49 ms |
728 KB |
Output is correct |
4 |
Correct |
8 ms |
716 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
732 KB |
Output is correct |
2 |
Correct |
49 ms |
740 KB |
Output is correct |
3 |
Correct |
50 ms |
716 KB |
Output is correct |
4 |
Correct |
8 ms |
728 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
20 ms |
732 KB |
Output is correct |
2 |
Correct |
46 ms |
712 KB |
Output is correct |
3 |
Correct |
92 ms |
724 KB |
Output is correct |
4 |
Correct |
8 ms |
728 KB |
Output is correct |
5 |
Correct |
10 ms |
720 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
355 ms |
4848 KB |
Output is correct |
2 |
Execution timed out |
1061 ms |
5800 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
129 ms |
5032 KB |
Output is correct |
2 |
Correct |
118 ms |
4756 KB |
Output is correct |
3 |
Correct |
128 ms |
5036 KB |
Output is correct |
4 |
Correct |
117 ms |
4992 KB |
Output is correct |
5 |
Correct |
115 ms |
5208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1039 ms |
5296 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1020 ms |
6204 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
438 ms |
5584 KB |
Output is correct |
2 |
Execution timed out |
1053 ms |
5656 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1008 ms |
24304 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1026 ms |
24352 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1066 ms |
37456 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1070 ms |
36276 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1031 ms |
39816 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1053 ms |
39612 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1065 ms |
43448 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1037 ms |
42324 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1040 ms |
48228 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1058 ms |
48160 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |