#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) * double(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 |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 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 |
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 |
1 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 |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
348 KB |
Output is correct |
2 |
Correct |
3 ms |
348 KB |
Output is correct |
3 |
Correct |
2 ms |
344 KB |
Output is correct |
4 |
Correct |
2 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
344 KB |
Output is correct |
2 |
Correct |
2 ms |
348 KB |
Output is correct |
3 |
Correct |
2 ms |
500 KB |
Output is correct |
4 |
Correct |
2 ms |
516 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
352 KB |
Output is correct |
3 |
Correct |
2 ms |
464 KB |
Output is correct |
4 |
Correct |
3 ms |
356 KB |
Output is correct |
5 |
Correct |
2 ms |
360 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
28 ms |
1508 KB |
Output is correct |
2 |
Correct |
20 ms |
880 KB |
Output is correct |
3 |
Correct |
16 ms |
1028 KB |
Output is correct |
4 |
Correct |
20 ms |
1640 KB |
Output is correct |
5 |
Correct |
9 ms |
736 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
15 ms |
1036 KB |
Output is correct |
2 |
Correct |
17 ms |
992 KB |
Output is correct |
3 |
Correct |
22 ms |
1500 KB |
Output is correct |
4 |
Correct |
33 ms |
1500 KB |
Output is correct |
5 |
Correct |
23 ms |
1500 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
25 ms |
1500 KB |
Output is correct |
2 |
Correct |
19 ms |
988 KB |
Output is correct |
3 |
Correct |
21 ms |
1500 KB |
Output is correct |
4 |
Correct |
40 ms |
1496 KB |
Output is correct |
5 |
Correct |
18 ms |
992 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
22 ms |
1064 KB |
Output is correct |
2 |
Correct |
21 ms |
1064 KB |
Output is correct |
3 |
Correct |
22 ms |
492 KB |
Output is correct |
4 |
Correct |
40 ms |
1500 KB |
Output is correct |
5 |
Correct |
26 ms |
1500 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
32 ms |
1496 KB |
Output is correct |
2 |
Correct |
21 ms |
992 KB |
Output is correct |
3 |
Correct |
14 ms |
604 KB |
Output is correct |
4 |
Correct |
29 ms |
1500 KB |
Output is correct |
5 |
Correct |
40 ms |
1500 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
170 ms |
6592 KB |
Output is correct |
2 |
Correct |
65 ms |
552 KB |
Output is correct |
3 |
Correct |
64 ms |
560 KB |
Output is correct |
4 |
Correct |
132 ms |
5320 KB |
Output is correct |
5 |
Correct |
116 ms |
5308 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
66 ms |
848 KB |
Output is correct |
2 |
Correct |
205 ms |
6180 KB |
Output is correct |
3 |
Correct |
74 ms |
1492 KB |
Output is correct |
4 |
Correct |
125 ms |
5008 KB |
Output is correct |
5 |
Correct |
126 ms |
6600 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
175 ms |
10432 KB |
Output is correct |
2 |
Correct |
76 ms |
344 KB |
Output is correct |
3 |
Correct |
77 ms |
536 KB |
Output is correct |
4 |
Correct |
146 ms |
9516 KB |
Output is correct |
5 |
Correct |
132 ms |
4596 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
80 ms |
348 KB |
Output is correct |
2 |
Correct |
232 ms |
9920 KB |
Output is correct |
3 |
Correct |
75 ms |
1492 KB |
Output is correct |
4 |
Correct |
155 ms |
9400 KB |
Output is correct |
5 |
Correct |
146 ms |
10176 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
192 ms |
9148 KB |
Output is correct |
2 |
Correct |
90 ms |
468 KB |
Output is correct |
3 |
Correct |
108 ms |
348 KB |
Output is correct |
4 |
Correct |
170 ms |
9512 KB |
Output is correct |
5 |
Correct |
145 ms |
5832 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
101 ms |
480 KB |
Output is correct |
2 |
Correct |
258 ms |
9404 KB |
Output is correct |
3 |
Correct |
99 ms |
1488 KB |
Output is correct |
4 |
Correct |
179 ms |
9212 KB |
Output is correct |
5 |
Correct |
164 ms |
9884 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
253 ms |
10432 KB |
Output is correct |
2 |
Correct |
101 ms |
468 KB |
Output is correct |
3 |
Correct |
117 ms |
348 KB |
Output is correct |
4 |
Correct |
193 ms |
9516 KB |
Output is correct |
5 |
Correct |
195 ms |
10584 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
105 ms |
344 KB |
Output is correct |
2 |
Correct |
284 ms |
9404 KB |
Output is correct |
3 |
Correct |
108 ms |
1492 KB |
Output is correct |
4 |
Correct |
191 ms |
9404 KB |
Output is correct |
5 |
Correct |
184 ms |
10428 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
278 ms |
8892 KB |
Output is correct |
2 |
Correct |
129 ms |
592 KB |
Output is correct |
3 |
Correct |
167 ms |
344 KB |
Output is correct |
4 |
Correct |
241 ms |
10204 KB |
Output is correct |
5 |
Correct |
218 ms |
9916 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
132 ms |
480 KB |
Output is correct |
2 |
Correct |
346 ms |
8896 KB |
Output is correct |
3 |
Correct |
135 ms |
2560 KB |
Output is correct |
4 |
Correct |
240 ms |
10172 KB |
Output is correct |
5 |
Correct |
262 ms |
10428 KB |
Output is correct |