Submission #1093060

#TimeUsernameProblemLanguageResultExecution timeMemory
1093060TommasoUlianMobile (BOI12_mobile)C++17
0 / 100
720 ms45836 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; vector<pair<double, double>> torri; ll n, L; bool good(double r) { queue<pair<double, double>> s; for (auto a : torri) { double x = a.first, y = a.second; if (abs(y) <= r - 1e-6) { // Ensure we're within the valid range double dx = sqrt((r + y) * (r - y)); s.push({x - dx, x + dx}); } } double curr = 0; while (!s.empty()) { if (curr >= L) return true; // Early exit if covered auto seg = s.front(); s.pop(); if (seg.first <= curr) { curr = max(seg.second, curr); } else { return false; // Can't cover this gap } } return curr >= L; // Final check } void solve() { cin >> n >> L; torri.resize(n); for (int i = 0; i < n; i++) { cin >> torri[i].first >> torri[i].second; } double l = 1, r = 2e9; // Set realistic bounds double ans = r; while (r - l > 1e-4) { // Tighter precision for convergence double c = (r + l) / 2; if (good(c)) { ans = c; r = c; } else { l = c; } } cout << setprecision(18) << (l + r) / 2 << endl; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); solve(); return 0; }

Compilation message (stderr)

mobile.cpp: In function 'void solve()':
mobile.cpp:42:12: warning: variable 'ans' set but not used [-Wunused-but-set-variable]
   42 |     double ans = r;
      |            ^~~
#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...