This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
double mid(int x1, int y1, int x2, int y2){
return (double)(x2*x2 - x1*x1 + y2*y2 - y1*y1)/(double)(2*x2-2*x1);
}
double dist(double x1, double y1, double x2, double y2){
return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}
signed main(){
int n,l; cin>>n>>l;
map<int,int> mp;
for (int i=0; i<n; i++){
int p,q; cin>>p>>q;
q=abs(q);
if (mp.count(p)==0) mp[p]=q;
mp[p] = min(mp[p], q);
}
n=(int)(mp.size());
vector<int> x, y;
for (auto [i,j]: mp){
x.push_back(i), y.push_back(j);
}
vector<double> a(n,0), b(n,l);
stack<int> sl;
//cout<<'\n';
for (int i=0; i<n; i++){
double cur = 0;
while (!sl.empty()) {
cur = max(cur, mid(x[i],y[i],x[sl.top()],y[sl.top()]));
if (y[i] >= y[sl.top()]) break;
sl.pop();
}
a[i] = cur;
//a[i] = min((double)l,a[i]);
//cout<<i<<' '<<cur<<'\n';
//ans=max(ans, dist(x[i],y[i],cur,0));
sl.push(i);
}
stack<int> sr;
//cout<<'\n';
for (int i=n-1; i>=0; i--){
double cur = l;
while (!sr.empty()) {
cur = min(cur, mid(x[i],y[i],x[sr.top()],y[sr.top()]));
if (y[i] >= y[sr.top()]) break;
sr.pop();
}
b[i] = cur;
//b[i]=max((double)0, b[i]);
//cout<<i<<' '<<cur<<'\n';
//ans=max(ans, dist(x[i],y[i],cur,0));
sr.push(i);
}
double ans=0;
for (int i=0; i<n; i++){
if (a[i]<0 or a[i]>l or b[i]<0 or b[i]>l or a[i]>b[i]) continue;
//a[i] = min((double)l,a[i]);
//b[i] = max((double)0, b[i]);
ans=max(ans, dist(x[i],y[i],a[i],0));
ans=max(ans, dist(x[i],y[i],b[i],0));
}
//if (ans>=12 and ans<=12.1){
// cout<<l<<'\n';
//}
cout << fixed << setprecision(6) << ans << endl;
}
# | 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... |