Submission #417455

#TimeUsernameProblemLanguageResultExecution timeMemory
417455jackkkkMobile (BOI12_mobile)C++11
0 / 100
1094 ms32432 KiB
#include <bits/stdc++.h> using namespace std; int n, l; vector <pair<double, double>> towers; vector <pair<double ,double>> intervals; bool good(double dist){ intervals.clear(); //get_intervals double mx = 0; for(const auto &tower : towers){ if(tower.second>dist){ intervals.emplace_back(0, 0); continue; } double range = sqrt((dist*dist)-(tower.second*tower.second)); intervals.emplace_back(tower.first-range, tower.first+range); mx = max(mx, tower.first+range); } sort(intervals.begin(), intervals.end()); if(intervals[0].first>0 || mx<l){ return false; } double curr_max = intervals[0].second; for(int i = 1; i < (int) intervals.size(); i++){ if(intervals[i].first>l){ return true; } if(curr_max<intervals[i].first){ return false; } curr_max=max(curr_max, intervals[i].second); } return true; } int main() { // your code goes here cin >> n >> l; towers.resize(n); for(int i = 0; i < n; i++){ cin >> towers[i].first >> towers[i].second; } double s = 0, e = 300000, mid; while(e-s>0.001){ mid = (s+e)/2; if(good(mid)){ e=mid; } else{ s=mid; } } cout << e << "\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...