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 (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
}
signed main(){
int n,l; cin>>n>>l;
vector<int> x(n), y(n);
for (int i=0; i<n; i++) cin>>x[i]>>y[i];
vector<int> a(n,0), b(n,l);
stack<int> sl;
//cout<<'\n';
double ans=0;
for (int i=0; i<n; i++){
double cur = a[i];
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();
}
//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 = b[i];
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();
}
//cout<<i<<' '<<cur<<'\n';
ans=max(ans, dist(x[i],y[i],cur,0));
sr.push(i);
}
cout<<sqrt(ans)<<'\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... |