Submission #973181

#TimeUsernameProblemLanguageResultExecution timeMemory
973181IdanRosenMobile (BOI12_mobile)C++98
0 / 100
1058 ms47424 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> pll; typedef long double ld; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); ll n, l; cin >> n >> l; vector<pll> arr(n); for (auto &ref: arr) cin >> ref.first >> ref.second; ld start = 0; ld end = 1e9; while (end - start > 1e-6) { ld mid = start + (end - start) / 2; bool check; { vector<pair<ld, ld>> ranges(n); for (int i = 0; i < n; i++) { ll center = arr[i].first; ld delta = sqrt(pow(mid, 2) - pow(arr[i].second, 2)); ranges[i] = {center - delta, center + delta}; } std::sort(ranges.begin(), ranges.end()); pair<ld,ld> combined = ranges[0]; for (int i = 1; i < n; i++) { pair<ld,ld>& curr = ranges[i]; if (combined.second < curr.first) { check = false; break; } combined.second = curr.second; } if (combined.first <= 0 && l <= combined.second) check = true; } if (check) end = mid; else start = mid; } cout << setprecision(6) << start << endl; }

Compilation message (stderr)

mobile.cpp: In function 'int main()':
mobile.cpp:50:9: warning: 'check' may be used uninitialized in this function [-Wmaybe-uninitialized]
   50 |         if (check)
      |         ^~
#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...