#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
#define pii array<int,2>
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n,t;cin>>n>>t;
vector<pii> v(n);
for (auto &x:v)cin>>x[0]>>x[1];
vector<pii> tt;
for (auto &x:v) {
if (!tt.size()) {
tt.push_back(x);
}
else if (tt.back()[0] == x[0] && abs(tt.back()[1]) > abs(x[1])) {
tt.pop_back();
}
tt.push_back(x);
}
// v=tt;
n=v.size();
long double l = 1;
long double r = 1e10;
cout<<setprecision(15);
// for (auto &x:v) {
// r = min(r, (long double)max(sqrt(x[0]*x[0] + x[1]*x[1]), sqrt((x[0]-t)*(x[0]-t) + x[1]*x[1])));
// }
// cout<<r<<"\n";
vector<bool> rem(n, false);
while (abs(l-r) > 0.0001) {
long double m = (l+r)/2.0;
int i=0;
vector<array<long double,2>> start;
bool all=false;
for (auto &x:v) {
if ((double)abs(x[1]) >= m) {
rem[i]=true;
}
// if (rem[i]) {
// i++;
// continue;
// }
else {
long double aa=(double)abs(x[1]);
long double dis=sqrt(m*m-aa*aa);
array<long double,2> pos1 = {x[0]-dis,x[0]+dis};
if ((pos1[0] < 0.0 && pos1[1] < 0.0) || (pos1[0] > (double)t && pos1[1] > (double)t)) {
rem[i]=true;
}
else {
pos1[0]=max(pos1[0], (long double)0.0);
pos1[1]=min(pos1[1], (long double)t);
if (pos1[0] == 0.0 && pos1[1] == t) {
all=true;
break;
}
start.push_back(pos1);
}
}
i++;
}
if (all) {
r=m;
continue;
}
bool possible=true;
double e=0.0;
for (auto &x:start) {
if (x[0] <= e && x[1] > e) {
e=x[1];
}
}
if (e<t) possible=false;
if (possible) {
r=m;
// int cnt=0;
// int pt=0;
// for (int i=0;i<n;i++) {
// if (rem[i]) {
// cnt++;
// }
// else if (cnt != 0) {
// swap(v[i], v[pt]);
// }
// if (!rem[i]) {
// pt++;
// }
// }
// n -= cnt;
// while (v.size() != n){
// v.pop_back();
// rem.pop_back();
// }
// for (int i=0;i<n;i++) {
// rem[i]=false;
// }
}
else {
l=m;
// for (i=0;i<n;i++) {
// rem[i]=false;
// }
}
}
cout<<r<<"\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
600 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 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 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
604 KB |
Output is correct |
2 |
Correct |
3 ms |
808 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
2 ms |
604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
604 KB |
Output is correct |
2 |
Correct |
6 ms |
1332 KB |
Output is correct |
3 |
Correct |
3 ms |
904 KB |
Output is correct |
4 |
Correct |
2 ms |
720 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
856 KB |
Output is correct |
2 |
Correct |
6 ms |
1012 KB |
Output is correct |
3 |
Correct |
3 ms |
904 KB |
Output is correct |
4 |
Correct |
2 ms |
604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
764 KB |
Output is correct |
2 |
Correct |
6 ms |
1112 KB |
Output is correct |
3 |
Correct |
3 ms |
880 KB |
Output is correct |
4 |
Correct |
2 ms |
604 KB |
Output is correct |
5 |
Correct |
2 ms |
604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
45 ms |
7164 KB |
Output is correct |
2 |
Correct |
67 ms |
11840 KB |
Output is correct |
3 |
Correct |
51 ms |
6024 KB |
Output is correct |
4 |
Correct |
24 ms |
5072 KB |
Output is correct |
5 |
Correct |
11 ms |
2720 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
19 ms |
3900 KB |
Output is correct |
2 |
Correct |
20 ms |
4508 KB |
Output is correct |
3 |
Correct |
24 ms |
5332 KB |
Output is correct |
4 |
Correct |
30 ms |
5648 KB |
Output is correct |
5 |
Correct |
32 ms |
5816 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
112 ms |
10424 KB |
Output is correct |
2 |
Correct |
57 ms |
11280 KB |
Output is correct |
3 |
Correct |
44 ms |
7960 KB |
Output is correct |
4 |
Correct |
37 ms |
6520 KB |
Output is correct |
5 |
Correct |
27 ms |
5064 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
90 ms |
11100 KB |
Output is correct |
2 |
Correct |
75 ms |
11904 KB |
Output is correct |
3 |
Correct |
56 ms |
11640 KB |
Output is correct |
4 |
Correct |
37 ms |
6556 KB |
Output is correct |
5 |
Correct |
29 ms |
6132 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
84 ms |
10372 KB |
Output is correct |
2 |
Correct |
77 ms |
11408 KB |
Output is correct |
3 |
Correct |
55 ms |
12464 KB |
Output is correct |
4 |
Correct |
36 ms |
6552 KB |
Output is correct |
5 |
Correct |
29 ms |
5936 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
692 ms |
48480 KB |
Output is correct |
2 |
Correct |
407 ms |
48416 KB |
Output is correct |
3 |
Correct |
411 ms |
55816 KB |
Output is correct |
4 |
Correct |
174 ms |
39864 KB |
Output is correct |
5 |
Correct |
141 ms |
29316 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
421 ms |
48472 KB |
Output is correct |
2 |
Correct |
403 ms |
49480 KB |
Output is correct |
3 |
Correct |
389 ms |
50756 KB |
Output is correct |
4 |
Correct |
166 ms |
33784 KB |
Output is correct |
5 |
Correct |
146 ms |
35520 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1030 ms |
70948 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
695 ms |
69496 KB |
Output is correct |
2 |
Correct |
468 ms |
57160 KB |
Output is correct |
3 |
Correct |
334 ms |
59004 KB |
Output is correct |
4 |
Correct |
234 ms |
44912 KB |
Output is correct |
5 |
Correct |
179 ms |
40916 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1020 ms |
73976 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
681 ms |
74136 KB |
Output is correct |
2 |
Correct |
563 ms |
81932 KB |
Output is correct |
3 |
Correct |
455 ms |
65476 KB |
Output is correct |
4 |
Correct |
235 ms |
51136 KB |
Output is correct |
5 |
Correct |
211 ms |
49000 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1056 ms |
75592 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
870 ms |
76804 KB |
Output is correct |
2 |
Correct |
602 ms |
88932 KB |
Output is correct |
3 |
Correct |
558 ms |
87632 KB |
Output is correct |
4 |
Correct |
321 ms |
58728 KB |
Output is correct |
5 |
Correct |
242 ms |
52416 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1049 ms |
82712 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
915 ms |
83140 KB |
Output is correct |
2 |
Correct |
766 ms |
97028 KB |
Output is correct |
3 |
Correct |
804 ms |
94412 KB |
Output is correct |
4 |
Correct |
357 ms |
77292 KB |
Output is correct |
5 |
Correct |
306 ms |
72928 KB |
Output is correct |