#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;
}
start.push_back({0.0, 0.0});
start.push_back({(double)t,(double)t});
sort(start.begin(),start.end());
// cout<<m<<" "<<l<<" "<<r<<"\n";
// for (auto &x:start) {
// cout<<x[0]<<" "<<x[1]<<"\n";
// }
// cout<<"\n";
// for (auto &x:v) {
// cout<<x[0]<<" "<<x[1]<<"\n";
// }
// cout<<"\n\n";
array<long double,2> pos={0.0, 0.0};
bool possible=true;
for (auto &x:start) {
if (x[0] <= pos[1]) {
pos[1]=max(pos[1], x[1]);
}
else {
possible=false;
break;
}
}
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";
}
Compilation message
mobile.cpp: In function 'int main()':
mobile.cpp:140:29: warning: comparison of integer expressions of different signedness: 'std::vector<std::array<long int, 2> >::size_type' {aka 'long unsigned int'} and 'int64_t' {aka 'long int'} [-Wsign-compare]
140 | while (v.size() != n){
| ~~~~~~~~~^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 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 |
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 |
6 ms |
812 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
3 ms |
604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
756 KB |
Output is correct |
2 |
Correct |
17 ms |
1128 KB |
Output is correct |
3 |
Correct |
11 ms |
904 KB |
Output is correct |
4 |
Correct |
2 ms |
604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
18 ms |
1112 KB |
Output is correct |
3 |
Correct |
11 ms |
912 KB |
Output is correct |
4 |
Correct |
2 ms |
592 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
856 KB |
Output is correct |
2 |
Correct |
18 ms |
1120 KB |
Output is correct |
3 |
Correct |
12 ms |
916 KB |
Output is correct |
4 |
Correct |
2 ms |
620 KB |
Output is correct |
5 |
Correct |
1 ms |
604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
66 ms |
6972 KB |
Output is correct |
2 |
Correct |
438 ms |
11636 KB |
Output is correct |
3 |
Correct |
175 ms |
6008 KB |
Output is correct |
4 |
Correct |
23 ms |
5064 KB |
Output is correct |
5 |
Correct |
8 ms |
2272 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
14 ms |
3548 KB |
Output is correct |
2 |
Correct |
15 ms |
3800 KB |
Output is correct |
3 |
Correct |
18 ms |
4792 KB |
Output is correct |
4 |
Correct |
18 ms |
5080 KB |
Output is correct |
5 |
Correct |
22 ms |
5336 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
463 ms |
11856 KB |
Output is correct |
2 |
Correct |
466 ms |
11348 KB |
Output is correct |
3 |
Correct |
360 ms |
8092 KB |
Output is correct |
4 |
Correct |
25 ms |
6100 KB |
Output is correct |
5 |
Correct |
17 ms |
4308 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
545 ms |
12812 KB |
Output is correct |
2 |
Correct |
615 ms |
12436 KB |
Output is correct |
3 |
Correct |
425 ms |
12612 KB |
Output is correct |
4 |
Correct |
25 ms |
6184 KB |
Output is correct |
5 |
Correct |
22 ms |
5608 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
201 ms |
8888 KB |
Output is correct |
2 |
Correct |
600 ms |
13216 KB |
Output is correct |
3 |
Correct |
457 ms |
12180 KB |
Output is correct |
4 |
Correct |
30 ms |
6092 KB |
Output is correct |
5 |
Correct |
21 ms |
5588 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1048 ms |
52128 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1103 ms |
55824 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1018 ms |
75236 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1010 ms |
79456 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1039 ms |
78940 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1073 ms |
82616 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1084 ms |
84632 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1025 ms |
87784 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1041 ms |
89272 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1083 ms |
95392 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |