Submission #995199

#TimeUsernameProblemLanguageResultExecution timeMemory
995199VMaksimoski008Mobile (BOI12_mobile)C++17
90 / 100
1052 ms48740 KiB
#include <bits/stdc++.h> #define int long long using namespace std; using ll = long long; using pdd = pair<double, double>; int32_t main() { int n, L; cin >> n >> L; vector<int> x(n), y(n); for(int i=0; i<n; i++) cin >> x[i] >> y[i]; double l=1, r=1.5e9, ans=r; for(int it=0; it<45; it++) { double mid = (l + r) / 2.0; vector<pdd> seg; for(int i=0; i<n; i++) { if(abs(y[i]) >= mid) continue; double len = sqrt(mid * mid - y[i] * y[i]); double left = x[i] - len, right = x[i] + len; if( right >= 0 && left <= L ) seg.push_back({ max((double)0, x[i] - len), min((double)L, x[i] + len) }); } if(seg.size() == 0) { l = mid; continue; } bool ok = 1; double mn = 1e9; for(auto &s : seg) mn = min(mn, s.first); if(mn > 0) ok = 0; double lp=seg[0].first, rp=seg[0].second; for(int i=1; i<seg.size(); i++) { if(seg[i].first <= rp) rp = max(rp, seg[i].second); } if(ok && rp >= L) ans = min(ans, mid), r = mid; else l = mid; } cout << setprecision(8) << fixed << ans << '\n'; return 0; }

Compilation message (stderr)

mobile.cpp: In function 'int32_t main()':
mobile.cpp:39:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<double, double> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |         for(int i=1; i<seg.size(); i++) {
      |                      ~^~~~~~~~~~~
mobile.cpp:37:16: warning: unused variable 'lp' [-Wunused-variable]
   37 |         double lp=seg[0].first, rp=seg[0].second;
      |                ^~
#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...