#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-4, max_sq = 4e18 + 1;
inline bool cmp_less(const double &a, const double &b) {
return a + eps < b;
}
inline bool cmp_equal(const double &a, const double &b) {
return abs(a - b) < eps;
}
inline bool cmp_less_equal(const double &a, const double &b) {
return cmp_less(a, b) || cmp_equal(a, b);
}
inline bool cmp_cor(const pair<double, double> &p1, const pair<double, double> &p2) {
return cmp_less(p1.first - sqrt(max_sq - p1.second * p1.second), p2.first - sqrt(max_sq - p2.second * p2.second));
}
int main() {
int n;
double len;
cin >> n >> len;
vector<pair<double, double>> cor(n);
for (int i = 0; i < n; i++)
cin >> cor[i].first >> cor[i].second;
// sort(cor.begin(), cor.end(), cmp_cor);
double l = 0, r = 1e10, m;
while (cmp_less(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))) {
double dx = sqrt(m * m - cor[i].second * cor[i].second);
range.push_back({cor[i].first - dx, cor[i].first + dx});
}
}
pair<double, double> cur_range = {-1, -1};
if (range.size() > 0) cur_range = range[0];
for (int i = 0; i < range.size(); i++) {
if (cmp_less_equal(range[i].first, cur_range.second) && cmp_less(cur_range.second, range[i].second))
cur_range.second = range[i].second;
if (!cmp_less_equal(range[i].first, cur_range.second) || 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 (cmp_less_equal(real_range[i].first, 0) && cmp_less_equal(len, real_range[i].second)) {
iok = true;
break;
}
}
if (iok)
r = m;
else
l = m + eps;
}
cout << setprecision(3) << fixed << r << endl;
return 0;
}
Compilation message
mobile.cpp: In function 'int main()':
mobile.cpp:43: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]
43 | for (int i = 0; i < range.size(); i++) {
| ~~^~~~~~~~~~~~~~
mobile.cpp:46:76: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<double, double> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
46 | if (!cmp_less_equal(range[i].first, cur_range.second) || i + 1 == range.size()) {
| ~~~~~~^~~~~~~~~~~~~~~
mobile.cpp:52: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]
52 | for (int i = 0; i < real_range.size(); i++) {
| ~~^~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
8 ms |
596 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
580 KB |
Output is correct |
2 |
Correct |
10 ms |
580 KB |
Output is correct |
3 |
Incorrect |
8 ms |
580 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
10 ms |
596 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
140 ms |
4788 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
119 ms |
4856 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
165 ms |
5152 KB |
Output is correct |
2 |
Incorrect |
182 ms |
5056 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
210 ms |
5572 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
226 ms |
5560 KB |
Output is correct |
2 |
Incorrect |
200 ms |
5564 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
979 ms |
24280 KB |
Output is correct |
2 |
Execution timed out |
1082 ms |
32004 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1075 ms |
24216 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1055 ms |
35552 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1074 ms |
35600 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1080 ms |
38680 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1074 ms |
38696 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1051 ms |
41812 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1075 ms |
41872 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1084 ms |
48056 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1073 ms |
15956 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |