Submission #884569

#TimeUsernameProblemLanguageResultExecution timeMemory
884569bedupakoMobile (BOI12_mobile)C++17
0 / 100
1030 ms48276 KiB
#include <bits/stdc++.h> using namespace std; #define all(x) x.begin(),x.end() typedef long long ll; const double E = 1e-9; bool good(vector<pair<double,double>>& x, double l){ int n = x.size(); sort(all(x)); stack<pair<double,double>> s; for(int i = 0; i < n; i++){ if(s.empty()){ s.push(x[i]); }else if(s.top().second >= x[i].first){ s.top().second = max(s.top().second,x[i].second); }else{ s.push(x[i]); } } if((int)s.size() == 1){ if(abs(s.top().first) <= E and abs(s.top().second-l) <= E){ return true; } } return false; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int n,l; cin >> n >> l; vector<double> x(n),y(n); for(int i = 0; i < n; i++){ cin >> x[i] >> y[i]; } double low = 0, high = 10; double ans = 0l; while(high - low >= E){ double R = (low + high)/2; vector<pair<double,double>> ranges; for(int i = 0; i < n; i++){ if(R < y[i]){ continue; }else{ double val = sqrt(R*R - y[i]*y[i]); ranges.emplace_back(max(0/1.0,(double)x[i]-val), min((double)l,(double)x[i]+val)); } } if(good(ranges,l)){ ans = R; high = R - E; }else{ low = R + E; } } cout << fixed << setprecision(3) << 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...