Submission #1096957

#TimeUsernameProblemLanguageResultExecution timeMemory
1096957ocasuMobile (BOI12_mobile)C++17
8 / 100
1064 ms131072 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 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 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...