This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define pii array<int,2>
#define MAXN 1000001
array<double,2> start[MAXN];
int point=0;
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n,t;cin>>n>>t;
vector<pii> v;
for (int i=0;i<n;i++) {
int a,b;cin>>a>>b;
if (v.size() && v.back()[0] == a) {
if (abs(v.back()[1]) > b) {
v.pop_back();
v.push_back({a,b});
}
}
else {
v.push_back({a,b});
}
}
n=v.size();
double l = 1;
double r = 1e10;
cout<<setprecision(15);
while (abs(l-r) > 0.001) {
point = 0;
double m = (l+r)/2.0;
int i=0;
bool all=false;
for (auto &x:v) {
if ((double)abs(x[1]) >= m) {
i++;
continue;
}
else {
double aa=(double)abs(x[1]);
double dis=sqrt(m*m-aa*aa);
array<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)) {
i++;
continue;
}
else {
pos1[0]=max(pos1[0], 0.0);
pos1[1]=min(pos1[1], (double)t);
if (pos1[0] == 0.0 && pos1[1] == t) {
all=true;
break;
}
start[point++] = pos1;
}
}
i++;
}
if (all) {
r=m;
continue;
}
bool possible=true;
double e=0.0;
for (int i=0;i<point;i++) {
if (start[i][0] <= e && start[i][1] > e) {
e=start[i][1];
}
}
if (e<t) possible=false;
if (possible) {
r=m;
}
else {
l=m;
}
}
cout<<r<<"\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |