#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(pow(mid, 2) - pow(a[i].y, 2)));
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(3) << 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++) {
| ~~^~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
344 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 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
344 KB |
Output is correct |
2 |
Correct |
2 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
2 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
3 ms |
504 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
25 ms |
1500 KB |
Output is correct |
2 |
Correct |
20 ms |
992 KB |
Output is correct |
3 |
Correct |
15 ms |
992 KB |
Output is correct |
4 |
Correct |
21 ms |
1500 KB |
Output is correct |
5 |
Correct |
9 ms |
736 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
992 KB |
Output is correct |
2 |
Correct |
19 ms |
992 KB |
Output is correct |
3 |
Correct |
23 ms |
1496 KB |
Output is correct |
4 |
Correct |
22 ms |
1500 KB |
Output is correct |
5 |
Correct |
23 ms |
1500 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 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 |
29 ms |
1496 KB |
Output is correct |
5 |
Correct |
19 ms |
992 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
992 KB |
Output is correct |
2 |
Correct |
20 ms |
988 KB |
Output is correct |
3 |
Correct |
14 ms |
600 KB |
Output is correct |
4 |
Correct |
26 ms |
1500 KB |
Output is correct |
5 |
Correct |
25 ms |
1596 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
31 ms |
1500 KB |
Output is correct |
2 |
Correct |
20 ms |
992 KB |
Output is correct |
3 |
Correct |
13 ms |
600 KB |
Output is correct |
4 |
Correct |
25 ms |
1416 KB |
Output is correct |
5 |
Correct |
27 ms |
1500 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
142 ms |
4808 KB |
Output is correct |
2 |
Correct |
65 ms |
556 KB |
Output is correct |
3 |
Correct |
64 ms |
592 KB |
Output is correct |
4 |
Correct |
123 ms |
5616 KB |
Output is correct |
5 |
Correct |
118 ms |
4612 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
79 ms |
596 KB |
Output is correct |
2 |
Correct |
188 ms |
6348 KB |
Output is correct |
3 |
Correct |
69 ms |
1492 KB |
Output is correct |
4 |
Correct |
123 ms |
5776 KB |
Output is correct |
5 |
Correct |
120 ms |
6344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
164 ms |
9924 KB |
Output is correct |
2 |
Correct |
77 ms |
496 KB |
Output is correct |
3 |
Correct |
87 ms |
344 KB |
Output is correct |
4 |
Correct |
150 ms |
9432 KB |
Output is correct |
5 |
Correct |
134 ms |
4816 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
80 ms |
508 KB |
Output is correct |
2 |
Correct |
227 ms |
9032 KB |
Output is correct |
3 |
Correct |
75 ms |
1528 KB |
Output is correct |
4 |
Correct |
149 ms |
10680 KB |
Output is correct |
5 |
Correct |
154 ms |
10420 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
191 ms |
10368 KB |
Output is correct |
2 |
Correct |
90 ms |
500 KB |
Output is correct |
3 |
Correct |
93 ms |
600 KB |
Output is correct |
4 |
Correct |
173 ms |
9012 KB |
Output is correct |
5 |
Correct |
149 ms |
5316 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
93 ms |
344 KB |
Output is correct |
2 |
Correct |
242 ms |
10220 KB |
Output is correct |
3 |
Correct |
102 ms |
1496 KB |
Output is correct |
4 |
Correct |
178 ms |
9148 KB |
Output is correct |
5 |
Correct |
173 ms |
9664 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
224 ms |
9916 KB |
Output is correct |
2 |
Correct |
104 ms |
704 KB |
Output is correct |
3 |
Correct |
98 ms |
344 KB |
Output is correct |
4 |
Correct |
235 ms |
10152 KB |
Output is correct |
5 |
Correct |
191 ms |
9408 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
108 ms |
348 KB |
Output is correct |
2 |
Correct |
279 ms |
9152 KB |
Output is correct |
3 |
Correct |
109 ms |
1608 KB |
Output is correct |
4 |
Correct |
199 ms |
9284 KB |
Output is correct |
5 |
Correct |
188 ms |
10180 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
291 ms |
10176 KB |
Output is correct |
2 |
Correct |
127 ms |
484 KB |
Output is correct |
3 |
Correct |
125 ms |
348 KB |
Output is correct |
4 |
Correct |
254 ms |
9136 KB |
Output is correct |
5 |
Correct |
232 ms |
10180 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
131 ms |
348 KB |
Output is correct |
2 |
Correct |
347 ms |
9152 KB |
Output is correct |
3 |
Correct |
137 ms |
2456 KB |
Output is correct |
4 |
Correct |
259 ms |
10436 KB |
Output is correct |
5 |
Correct |
247 ms |
8896 KB |
Output is correct |