Submission #888108

#TimeUsernameProblemLanguageResultExecution timeMemory
888108eysbutnoMobile (BOI12_mobile)C++11
0 / 100
1066 ms59068 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using pii = pair<int, int>; #define all(x) begin(x), end(x) #define ckmax(a, b) a = max(a, b) #define ckmin(a, b) a = min(a, b) #define pb push_back #define ins insert #define f first #define s second int main() { cin.tie(0) -> sync_with_stdio(0); int n, l; cin >> n >> l; vector<pii> loc(n); for (auto& i : loc) { cin >> i.f >> i.s; } auto len = [&](ld d, ld y) { return sqrt(pow(d, 2) - pow(y, 2)); }; auto check = [&](ld d) { vector<pair<ld, ld>> itvs; for (int i = 0; i < n; i++) { int x = loc[i].f, y = loc[i].s; if (y > d) continue; ld dx = len(d, y); itvs.pb({x - dx, x + dx}); } sort(all(itvs)); if (itvs[0].f > 0) { return false; } ld far = itvs[0].f; for (auto& i : itvs) { if (i.f > far) { return false; } ckmax(far, i.s); } return far >= l; }; ld low = 0, high = 3e9, prec = 1e-7, ans = -1; while (low <= high) { ld mid = (low + high) / 2; if (check(mid)) { ans = mid; high = mid - prec; } else { low = mid + prec; } } cout << setprecision(7); cout << low << '\n'; } /** * WHY DECIMAL PRECISION?? * * Binary search the minimum * distance needed to cover the * highway. That's the answer. */

Compilation message (stderr)

mobile.cpp: In function 'int main()':
mobile.cpp:48:22: warning: variable 'ans' set but not used [-Wunused-but-set-variable]
   48 |         prec = 1e-7, ans = -1;
      |                      ^~~
#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...