#include <bits/stdc++.h>
#define pow(x, y) (double)(pow(x, y))
using namespace std;
struct coord{
int x, y;
};
vector <coord> a;
int N, L;
/*double dis(int ax, ay, double ans) {
return (double)(sqrt(pow(ay, 2) + pow(ax - ans, 2)));
}
double distance(int i, int j) {
long long num = pow(a[i].y, 2) - pow(a[j].y, 2) - pow(a[j].x, 2) + pow(a[i].x, 2);
long long den = 2 * (-a[j].x + a[i].x);
if (den == 0) return sqrt(num);
double frac = (double)(num) / (double)(den);
return frac;
}*/
bool solve(double mid) {
double right(0);
for (int i(0); i < a.size(); i++) {
if (abs(a[i].y) > mid) continue;
double iLeft = (double)(a[i].x) - (double)(sqrt(mid * mid - double(a[i].y * a[i].y)));
double iRight = a[i].x + (a[i].x - iLeft);
if (iLeft <= right) right = max(right,iRight);
}
return (right >= L);
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> N >> L;
a.clear();
int x, y; cin >> x >> y;
a.push_back({x, y});
for (int i(0); i < N - 1; i++) {
int ax, ay;
cin >> ax >> ay;
if (ax == a[(int)(a.size() - 1)].x){
if (abs(ay) < abs(a[(int)(a.size() - 1)].y)) {
a[(int)(a.size() - 1)].y = ay;
}
else continue;
}
a.push_back({ax, ay});
}
double l(0), r(1e9);
while (r - l > 0.0003) {
double mid = l + (r - l) / 2;
if (solve(mid)){
r = mid;
}
else l = mid;
}
cout << setprecision(5) << fixed << l << '\n';
return 0;
}
Compilation message
mobile.cpp: In function 'bool solve(double)':
mobile.cpp:25:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<coord>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
25 | for (int i(0); i < a.size(); i++) {
| ~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 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 |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 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 |
# |
결과 |
실행 시간 |
메모리 |
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 |
2 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
344 KB |
Output is correct |
2 |
Correct |
2 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
2 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
344 KB |
Output is correct |
2 |
Correct |
2 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Incorrect |
2 ms |
348 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
30 ms |
1500 KB |
Output is correct |
2 |
Incorrect |
20 ms |
992 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
15 ms |
992 KB |
Output is correct |
2 |
Correct |
17 ms |
992 KB |
Output is correct |
3 |
Correct |
19 ms |
1500 KB |
Output is correct |
4 |
Correct |
24 ms |
1500 KB |
Output is correct |
5 |
Incorrect |
25 ms |
1496 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
28 ms |
1908 KB |
Output is correct |
2 |
Incorrect |
19 ms |
988 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
21 ms |
992 KB |
Output is correct |
2 |
Incorrect |
23 ms |
988 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
30 ms |
1496 KB |
Output is correct |
2 |
Incorrect |
24 ms |
992 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
131 ms |
6344 KB |
Output is correct |
2 |
Correct |
65 ms |
592 KB |
Output is correct |
3 |
Correct |
62 ms |
596 KB |
Output is correct |
4 |
Incorrect |
121 ms |
6340 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
67 ms |
592 KB |
Output is correct |
2 |
Correct |
191 ms |
6084 KB |
Output is correct |
3 |
Incorrect |
66 ms |
1500 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
160 ms |
9292 KB |
Output is correct |
2 |
Correct |
79 ms |
548 KB |
Output is correct |
3 |
Incorrect |
76 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
81 ms |
540 KB |
Output is correct |
2 |
Correct |
225 ms |
10568 KB |
Output is correct |
3 |
Incorrect |
85 ms |
1436 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
187 ms |
9156 KB |
Output is correct |
2 |
Correct |
100 ms |
488 KB |
Output is correct |
3 |
Correct |
86 ms |
536 KB |
Output is correct |
4 |
Incorrect |
173 ms |
10304 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
99 ms |
344 KB |
Output is correct |
2 |
Correct |
253 ms |
9856 KB |
Output is correct |
3 |
Incorrect |
100 ms |
1488 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
217 ms |
9660 KB |
Output is correct |
2 |
Correct |
107 ms |
488 KB |
Output is correct |
3 |
Correct |
98 ms |
476 KB |
Output is correct |
4 |
Incorrect |
190 ms |
10696 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
118 ms |
540 KB |
Output is correct |
2 |
Correct |
284 ms |
10180 KB |
Output is correct |
3 |
Incorrect |
117 ms |
1492 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
275 ms |
9668 KB |
Output is correct |
2 |
Correct |
127 ms |
484 KB |
Output is correct |
3 |
Incorrect |
123 ms |
344 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
135 ms |
468 KB |
Output is correct |
2 |
Correct |
367 ms |
9152 KB |
Output is correct |
3 |
Incorrect |
132 ms |
2568 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |