Submission #829826

#TimeUsernameProblemLanguageResultExecution timeMemory
829826soumyojit_senMobile (BOI12_mobile)C++14
100 / 100
590 ms30716 KiB
#include <iostream> #include <vector> #include <math.h> #include <iomanip> using namespace std; vector<pair<double, double>> pts; int n; double L; bool works(double d){ // whether a radius of d is enough to intersect all the circles double currDistCovered = 0.0; for(int i = 0; i < n; i++){ // find the segment covered by ith circle on the highway // radius^2 = yi^2 + dist^2 double dist = sqrt(d*d - pts[i].second*pts[i].second); double start = pts[i].first - dist; double end = pts[i].first + dist; if(start <= currDistCovered){ currDistCovered = max(currDistCovered, end); } } return currDistCovered >= L; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cin >> n >> L; pts.resize(n); for(int i = 0; i < n; i++) cin >> pts[i].first >> pts[i].second; double good = 1.5e9; double bad = -1.0; for(int i = 0; i < 50; i++){ double mid = bad + (good - bad)/2; //cout << fixed << setprecision(6) << i << " " << mid <<"\n" ; if(works(mid)){ good = mid; } else { bad = mid; } } cout << fixed << setprecision(12) << good; }
#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...