Submission #854061

#TimeUsernameProblemLanguageResultExecution timeMemory
854061ventusliberumMobile (BOI12_mobile)C++17
0 / 100
1066 ms59412 KiB
/** * title: Mobile **/ #include <bits/stdc++.h> using namespace std; template <class T> istream &operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; } template <class T> ostream &operator<<(ostream &os, const vector<T> &v) { auto sep = ""; for (auto &x : v) os << exchange(sep, " ") << x; return os; } template <class T> vector<T> &operator+=(vector<T> &v, const T &a) { for (auto &x : v) x += a; return v; } template <class T> vector<T> &operator-=(vector<T> &v, const T &a) { for (auto &x : v) x -= a; return v; } template <class T, class U> inline bool chmax(T &a, const U &b) { return (a < b ? a = b, 1 : 0); } template <class T, class U> inline bool chmin(T &a, const U &b) { return (b < a ? a = b, 1 : 0); } #define si(x) int(x.size()) #define all(x) (x).begin(),(x).end() #define rall(x) (x).rbegin(),(x).rend() #define fi first #define se second using ll = long long; using ld = long double; constexpr int inf = 1001001001; constexpr long long infll = 4004004004004004004LL; constexpr long double eps = 1e-6; int main() { ios::sync_with_stdio(false); cin.tie(0); int N, L; cin >> N >> L; vector<int> X(N), Y(N); for (int i = 0; i < N; i++) { cin >> X[i] >> Y[i]; } auto valid = [&](ld d) { vector<pair<ld, ld>> V; for (int i = 0; i < N; i++) { if (abs(Y[i]) > d) continue; ld t = sqrt(d * d - Y[i] * Y[i]); ld lhs = X[i] - t; chmax(lhs, 0); ld rhs = X[i] + t; chmin(rhs, L); V.emplace_back(lhs, rhs); } sort(all(V)); if (V.empty()) return false; ld rhs = 0; for (int i = 0; i < si(V); i++) { if (rhs < V[i].fi) return false; chmax(rhs, V[i].se); } return rhs >= L; }; ld l = 0, r = inf * 2; while (r - l > eps) { ld mid = (l + r) / 2; valid(mid) ? r = mid : l = mid; } cout << fixed << setprecision(6) << l << '\n'; }
#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...