Submission #932350

#TimeUsernameProblemLanguageResultExecution timeMemory
932350HuyATMobile (BOI12_mobile)C++14
0 / 100
1070 ms82476 KiB
#include<bits/stdc++.h> const int MaxN = 1e6 + 10; const long double Eps = 1e-6; const long double MaxV = 1e18; int n; long double length,x[MaxN + 1],y[MaxN + 1]; void readData(){ std::cin >> n >> length; for(int i = 1;i <= n;++i){ std::cin >> x[i] >> y[i]; } } bool f(long double mid){ // bool found = false; long double l = 1e10,r = 1e10; std::vector<std::pair<long double,long double>> v; for(int i = 1;i <= n;++i){ if(mid < y[i]){ continue; } long double distance = sqrt(mid * mid - y[i] * y[i]); v.emplace_back(x[i] - distance,x[i] + distance); } std::sort(v.begin(),v.end()); if(v.empty()){ return false; } l = v[0].first; r = v[0].second; // long double l = 1e10,r = 1e10; for(int i = 1;i < (int)v.size();++i){ if(v[i].first > r){ return false; } r = std::max(r,v[i].second); } return (l <= 0 && r >= length); } long double solve(long double lo,long double hi){ while(hi - lo > Eps){ long double mid = (lo + hi) / 2; if(f(mid)){ hi = mid; }else{ lo = mid; } // std::cerr << mid << "\n"; } return hi; } int main(){ std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr);std::cout.tie(nullptr); readData(); std::cout << std::fixed << std::setprecision(8) << solve(0,MaxV * 2); return 0; }
#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...