Submission #888106

#TimeUsernameProblemLanguageResultExecution timeMemory
888106eysbutnoMobile (BOI12_mobile)C++17
0 / 100
1057 ms56120 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(n); for (int i = 0; i < n; i++) { int x = loc[i].f, y = loc[i].s; ld dx = len(d, y); itvs[i] = {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; // change }; ld low = 0, high = 3e9, prec = 1e-5; while (high - low > prec) { ld mid = (low + high) / 2; if (check(mid)) high = mid; else low = mid; } cout << setprecision(6); cout << low << '\n'; } /** * WHY DECIMAL PRECISION?? * * Binary search the minimum * distance needed to cover the * highway. That's the answer. */
#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...