Submission #768938

#TimeUsernameProblemLanguageResultExecution timeMemory
768938orcslopMobile (BOI12_mobile)C++17
100 / 100
672 ms35324 KiB
#include <bits/stdc++.h> using namespace std; #define sz(x) (int)(x).size() const int MAXN = 1e6; int n; double l; pair<double, double> v[MAXN]; bool check(double rad){ vector<pair<double, double>> intervals; double curr = 0; for(int i = 0; i < n; i++){ double dist = 0; if(0 <= v[i].first && v[i].first <= l){ dist = v[i].second; } else if(v[i].first < 0){ dist = sqrt(v[i].first * v[i].first + v[i].second + v[i].second); } else { dist=sqrt((v[i].first-l) * (v[i].first - l) + v[i].second * v[i].second); } if(dist < rad){ pair<double, double> range; range.first = v[i].first - sqrt(rad * rad - v[i].second * v[i].second); range.second = v[i].first + sqrt(rad * rad - v[i].second * v[i].second); if(range.first <= curr) curr = max(curr, range.second); // else return false; } } return curr >= l; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> n >> l; for(int i = 0; i < n; i++){ cin >> v[i].first >> v[i].second; } // cout << check(5.55); double low = 0, high = (double) 2e9; while (low + 0.00001 < high) { double mid = low + (high - low) / 2; if (check(mid)) high = mid; else low = mid; } cout << setprecision(15) << low << '\n'; 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...