#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define MAXN 1000005
#define FOR(i, a, b) for(ll i = a; i <= b; i++)
#define f first
#define s second
ll n;
db l;
vector<pair<db, db>> s;
bool overlap(pair<db, db> a, pair<db, db> b){ // does a overlap b vertex?
db ad = (a.f - b.f) * (a.f - b.f) + a.s * a.s;
db bd = b.s * b.s;
return ad <= bd;
}
db overlap2(pair<db, db> a, pair<db, db> b){
db x = (a.f * a.f + a.s * a.s - b.f * b.f - b.s * b.s) / (2 * (a.f - b.f));
// cout << " HERE: " << x << endl;
x = max((db)0, x);
x = min(x, l);
return min(sqrt((a.f - x) * (a.f - x) + a.s * a.s), sqrt((b.f - x) * (b.f - x) + b.s * b.s));
}
int main(){
cin >> n >> l;
FOR(i, 1, n){
db x, y; cin >> x >> y;
s.push_back({x, y});
}
sort(begin(s), end(s));
vector<pair<db, db>> s2;
ll prv = -1;
FOR(i, 0, n - 1){
if(prv == -1 || i == n - 1 || !(overlap(s[prv], s[i]) && overlap(s[i + 1], s[i]))){
s2.push_back(s[i]);
prv = i;
}
}
db r = max(sqrt(s2[0].f * s2[0].f + s2[0].s * s2[0].s), sqrt((s2.back().f - l) * (s2.back().f - l) + s2.back().s * s2.back().s));
// cout << "START PT IS " << (s2[0].f * s2[0].f + s2[0].s * s2[0].s) << endl;
// cout << "END PT IS " << ((s2.back().f - l) * (s2.back().f - l) + s2.back().s * s2.back().s) << endl;
FOR(i, 0, s2.size() - 2){
r = max(r, overlap2(s2[i], s2[i + 1]));
}
cout << fixed << setprecision(6) << r;
}
Compilation message
mobile.cpp: In function 'int main()':
mobile.cpp:6:38: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<double, double> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
6 | #define FOR(i, a, b) for(ll i = a; i <= b; i++)
......
49 | FOR(i, 0, s2.size() - 2){
| ~~~~~~~~~~~~~~~~~~~
mobile.cpp:49:5: note: in expansion of macro 'FOR'
49 | FOR(i, 0, s2.size() - 2){
| ^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
600 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
600 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
600 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
604 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
39 ms |
4088 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
42 ms |
5260 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
40 ms |
5308 KB |
Output is correct |
2 |
Incorrect |
50 ms |
4708 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
63 ms |
5312 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
66 ms |
6460 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
230 ms |
24760 KB |
Output is correct |
2 |
Incorrect |
322 ms |
28072 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
329 ms |
28740 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
280 ms |
39452 KB |
Output is correct |
2 |
Incorrect |
384 ms |
43668 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
403 ms |
44184 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
337 ms |
41900 KB |
Output is correct |
2 |
Incorrect |
452 ms |
46876 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
482 ms |
47336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
375 ms |
44436 KB |
Output is correct |
2 |
Incorrect |
556 ms |
49760 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
563 ms |
50656 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
496 ms |
49304 KB |
Output is correct |
2 |
Incorrect |
692 ms |
56212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
685 ms |
57240 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |