Submission #424409

#TimeUsernameProblemLanguageResultExecution timeMemory
424409winstonyinMobile (BOI12_mobile)C++11
4 / 100
1090 ms16856 KiB
#include <string> #include <iostream> #include <cstdio> #include <cstdlib> #include <algorithm> #include <vector> #include <cmath> #include <array> #include <map> #include <set> #include <fstream> #include <unordered_map> #include <queue> #include <iomanip> using namespace std; using pi = pair<int, int>; using pd = pair<double, double>; #define ll long long #define all(x) (x).begin(), (x).end() int n_stations, l_highway; vector<pd> locations; bool works(double radius) { double curr = 0; for(int i = 0; i < locations.size(); i++) { double delta = sqrt(radius*radius - locations[i].second*locations[i].second); double left = locations[i].first - delta, right = locations[i].first + delta; if(left <= curr) { curr = max(curr, right); } } return curr >= l_highway; } int main() { cin >> n_stations >> l_highway; for(int i = 0; i < n_stations; i++) { double x,y; cin >> x >> y; locations.push_back({x,y}); } double a = 0, b = 1.5e9; double ans; while(b - a >= 1e-3) { double m = (a+b)/2.0; if(works(m)) { b = m-0.00001; ans = m; } else { a = m+0.00001; } } cout << setprecision(4) << ans; return 0; }

Compilation message (stderr)

mobile.cpp: In function 'bool works(double)':
mobile.cpp:25:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<double, double> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |     for(int i = 0; i < locations.size(); i++) {
      |                    ~~^~~~~~~~~~~~~~~~~~
#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...