#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-5;
bool cmp_less(double a, double b) {
return a + eps < b;
}
bool cmp_less_equal(double a, double b) {
return a < b + eps;
}
bool cmp_range(pair<double, double> &p1, pair<double, double> &p2) {
return cmp_less(p1.first, p2.first);
}
bool inside(double l, double r, double m) {
return cmp_less_equal(l, m) && cmp_less_equal(m, r);
}
int main() {
int n, len;
cin >> n >> len;
vector<pair<int, int>> cor(n);
for (int i = 0; i < n; i++)
cin >> cor[i].first >> cor[i].second;
double l = 0, r = 2e9 + 7, m;
while (l < r) {
m = (l + r) / 2;
vector<pair<double, double>> range, real_range;
for (int i = 0; i < n; i++) {
if (cmp_less_equal(m, abs(cor[i].second))) continue;
double dx = sqrt(m * m - cor[i].second * cor[i].second);
range.push_back({cor[i].first - dx, cor[i].first + dx});
}
sort(range.begin(), range.end(), cmp_range);
pair<double, double> cur_range = {-1, -1};
if (range.size() > 0) cur_range = *range.begin();
for (int i = 0; i < range.size(); i++) {
if (inside(cur_range.first, cur_range.second, range[i].first) && cmp_less(cur_range.second, range[i].second))
cur_range.second = range[i].second;
if (!inside(cur_range.first, cur_range.second, range[i].first) || i + 1 == range.size()) {
real_range.push_back(cur_range);
cur_range = range[i];
}
}
bool iok = false;
for (int i = 0; i < real_range.size(); i++) {
if (inside(real_range[i].first, real_range[i].second, 0) && inside(real_range[i].first, real_range[i].second, len)) {
iok = true;
break;
}
}
if (iok)
r = m;
else
l = m + eps;
}
cout << setprecision(4) << fixed;
cout << r << endl;
return 0;
}
Compilation message
mobile.cpp: In function 'int main()':
mobile.cpp:41:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<double, double> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
41 | for (int i = 0; i < range.size(); i++) {
| ~~^~~~~~~~~~~~~~
mobile.cpp:44:85: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<double, double> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
44 | if (!inside(cur_range.first, cur_range.second, range[i].first) || i + 1 == range.size()) {
| ~~~~~~^~~~~~~~~~~~~~~
mobile.cpp:50:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<double, double> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
50 | for (int i = 0; i < real_range.size(); i++) {
| ~~^~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
296 KB |
Output is correct |
3 |
Correct |
1 ms |
300 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
296 KB |
Output is correct |
3 |
Execution timed out |
1074 ms |
296 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
340 KB |
Output is correct |
2 |
Execution timed out |
1072 ms |
440 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1071 ms |
596 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
592 KB |
Output is correct |
2 |
Correct |
19 ms |
612 KB |
Output is correct |
3 |
Correct |
31 ms |
596 KB |
Output is correct |
4 |
Correct |
9 ms |
616 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
18 ms |
596 KB |
Output is correct |
2 |
Correct |
20 ms |
616 KB |
Output is correct |
3 |
Correct |
35 ms |
580 KB |
Output is correct |
4 |
Incorrect |
8 ms |
628 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
291 ms |
5072 KB |
Output is correct |
2 |
Incorrect |
384 ms |
5328 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1075 ms |
4940 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
396 ms |
5168 KB |
Output is correct |
2 |
Incorrect |
432 ms |
5456 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
564 ms |
6316 KB |
Output is correct |
2 |
Execution timed out |
1079 ms |
6180 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1070 ms |
6372 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1062 ms |
24736 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1076 ms |
28500 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1076 ms |
35996 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1070 ms |
40688 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1068 ms |
39320 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1079 ms |
44668 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1036 ms |
36392 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1045 ms |
46604 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1058 ms |
48964 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1014 ms |
53792 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |