Submission #82076

#TimeUsernameProblemLanguageResultExecution timeMemory
82076FutymyCloneMobile (BOI12_mobile)C++14
50 / 100
1088 ms73952 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 5; const double eps = 1e-4; struct Point { int x, y; } a[N]; int n, m; bool check (double mid) { vector <pair <double, double> > vec; for (int i = 1; i <= n; i++) { //(a[i].x - x)^2 + a[i].y^2 = mid^2 double cur = mid * mid - 1LL * a[i].y * a[i].y; if (cur < 0) continue; double lx = -sqrt(cur) + a[i].x; double rx = sqrt(cur) + a[i].x; if (lx > m || rx < 0) continue; lx = max(lx, (double)0); rx = min(rx, (double)m); vec.push_back({lx, rx}); } sort(vec.begin(), vec.end()); double pt = 0; for (int i = 0; i < vec.size(); i++) { if (vec[i].first > pt) return false; pt = max(pt, vec[i].second); } if (pt < m) return false; return true; } int main(){ scanf("%d %d", &n, &m); for (int i = 1; i <= n; i++) scanf("%d %d", &a[i].x, &a[i].y); double l = 0, r = m; while (l + eps < r) { double mid = (l + r) / 2; if (check(mid)) r = mid; else l = mid; } cout << fixed << setprecision(10) << l; return 0; }

Compilation message (stderr)

mobile.cpp: In function 'bool check(double)':
mobile.cpp:31:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < vec.size(); i++) {
                     ~~^~~~~~~~~~~~
mobile.cpp: In function 'int main()':
mobile.cpp:41:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &n, &m);
     ~~~~~^~~~~~~~~~~~~~~~~
mobile.cpp:42:39: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for (int i = 1; i <= n; i++) scanf("%d %d", &a[i].x, &a[i].y);
                                  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...