제출 #417580

#제출 시각아이디문제언어결과실행 시간메모리
417580jackkkkMobile (BOI12_mobile)C++11
50 / 100
1097 ms48160 KiB
#include <stdio.h> #include <iomanip> #include <iostream> #include <string> #include <vector> #include <queue> #include <map> #include <array> #include <deque> #include <unordered_map> #include <unordered_set> #include <set> #include <algorithm> #include <stdlib.h> #include <math.h> #include <list> #include <float.h> #include <climits> using namespace std; void quit(){ cout.flush(); exit(0); } int n, l; vector <pair<double, double>> towers; bool good(double dist){ vector <pair<double ,double>> intervals; //get_intervals for(const auto &tower : towers){ if(abs(tower.second)>dist){ continue; } double range = sqrt((dist*dist)-(tower.second*tower.second)); intervals.emplace_back(tower.first-range, tower.first+range); } sort(intervals.begin(), intervals.end()); if(intervals.size()==0){ return false; } double s = intervals[0].first, f = intervals[0].second; intervals.emplace_back(1e50,1e50); //so that it iterates the last one for(size_t i = 1; i < intervals.size(); i++){ if(f<intervals[i].first){ if(s<=0 && f>=l){ return true; } s=intervals[i].first; f=intervals[i].second; } else{ f=max(f, intervals[i].second); } } return false; } int main() { //freopen("qwer.in", "r", stdin); //freopen("qwer.out", "w", stdout); ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> l; towers.resize(n); for(int i = 0; i < n; i++){ cin >> towers[i].first >> towers[i].second; } double s = 0, e = 1e10, mid; while(e-s>0.001){ mid = (s+e)/2; if(good(mid)){ e=mid; } else{ s=mid; } } cout << fixed << setprecision(10) <<e << "\n"; quit(); }
#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...