Submission #1096888

#TimeUsernameProblemLanguageResultExecution timeMemory
1096888ocasuMobile (BOI12_mobile)C++17
0 / 100
460 ms54880 KiB
#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]; for (int i=0; i<n; i++) y[i]=abs(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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...