Submission #1093071

#TimeUsernameProblemLanguageResultExecution timeMemory
1093071TommasoUlianMobile (BOI12_mobile)C++14
100 / 100
769 ms51752 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>> q; double curr = 0; for (auto a : torri) { double x = a.first, y = a.second; if(curr >= L)return true; if (abs(y) <= r - 1e-6) { double dx = sqrt((r + y) * (r - y)); double a = x-dx, b = x+dx; q.push({a,b}); } } while (!q.empty()) { if (curr >= L) return true; auto seg = q.front(); q.pop(); if (seg.first-1e-6 <= curr) { curr = max(seg.second, curr); } } return curr >= L; } 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; double ans = r; while (r - l > 1e-4) { 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:41:12: warning: variable 'ans' set but not used [-Wunused-but-set-variable]
   41 |     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...