Submission #854141

# Submission time Handle Problem Language Result Execution time Memory
854141 2023-09-26T08:30:37 Z ventusliberum Mobile (BOI12_mobile) C++17
100 / 100
439 ms 12836 KB
/**
 *    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;
constexpr int inf = 1001001001;
constexpr long long infll = 4004004004004004004LL;
constexpr 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 = [&](double d) {
        double p = 0;
        for (int i = 0; i < N; i++) {
            double t = sqrt(d * d - (ll)Y[i] * Y[i]);
            double lhs = X[i] - t, rhs = X[i] + t;
            if (p >= lhs) {
                chmax(p, rhs);
            }
        }
        return p >= L;
    };
    double l = 0, r = inf * 2;
    while (r - l > eps) {
        double mid = (l + r) / 2;
        valid(mid) ? r = mid : l = mid;
    }
    cout << fixed << setprecision(10) << l << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 460 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 460 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 348 KB Output is correct
2 Correct 2 ms 344 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 2 ms 568 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 38 ms 1048 KB Output is correct
2 Correct 21 ms 1624 KB Output is correct
3 Correct 15 ms 1368 KB Output is correct
4 Correct 31 ms 1880 KB Output is correct
5 Correct 15 ms 1112 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 1060 KB Output is correct
2 Correct 23 ms 1776 KB Output is correct
3 Correct 29 ms 1624 KB Output is correct
4 Correct 28 ms 1712 KB Output is correct
5 Correct 32 ms 2140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 1116 KB Output is correct
2 Correct 22 ms 1116 KB Output is correct
3 Correct 24 ms 1884 KB Output is correct
4 Correct 39 ms 2648 KB Output is correct
5 Correct 28 ms 1912 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 27 ms 1112 KB Output is correct
2 Correct 26 ms 1116 KB Output is correct
3 Correct 28 ms 1992 KB Output is correct
4 Correct 39 ms 2392 KB Output is correct
5 Correct 37 ms 2020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 27 ms 1112 KB Output is correct
2 Correct 27 ms 2132 KB Output is correct
3 Correct 27 ms 1880 KB Output is correct
4 Correct 40 ms 2396 KB Output is correct
5 Correct 52 ms 2000 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 119 ms 4360 KB Output is correct
2 Correct 135 ms 8460 KB Output is correct
3 Correct 134 ms 8276 KB Output is correct
4 Correct 193 ms 9312 KB Output is correct
5 Correct 173 ms 7760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 135 ms 4356 KB Output is correct
2 Correct 246 ms 7764 KB Output is correct
3 Correct 137 ms 7308 KB Output is correct
4 Correct 189 ms 9224 KB Output is correct
5 Correct 169 ms 8208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 141 ms 4960 KB Output is correct
2 Correct 163 ms 10004 KB Output is correct
3 Correct 159 ms 9752 KB Output is correct
4 Correct 226 ms 11088 KB Output is correct
5 Correct 208 ms 9500 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 163 ms 5140 KB Output is correct
2 Correct 287 ms 9236 KB Output is correct
3 Correct 163 ms 8788 KB Output is correct
4 Correct 234 ms 11088 KB Output is correct
5 Correct 209 ms 9748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 169 ms 5968 KB Output is correct
2 Correct 186 ms 11556 KB Output is correct
3 Correct 183 ms 11492 KB Output is correct
4 Correct 279 ms 12836 KB Output is correct
5 Correct 235 ms 5724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 193 ms 5720 KB Output is correct
2 Correct 326 ms 5972 KB Output is correct
3 Correct 190 ms 5724 KB Output is correct
4 Correct 257 ms 5724 KB Output is correct
5 Correct 236 ms 5724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 189 ms 6492 KB Output is correct
2 Correct 217 ms 6712 KB Output is correct
3 Correct 209 ms 6492 KB Output is correct
4 Correct 298 ms 6712 KB Output is correct
5 Correct 266 ms 6492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 221 ms 6488 KB Output is correct
2 Correct 365 ms 6740 KB Output is correct
3 Correct 212 ms 6716 KB Output is correct
4 Correct 301 ms 6648 KB Output is correct
5 Correct 277 ms 6716 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 235 ms 8284 KB Output is correct
2 Correct 268 ms 8284 KB Output is correct
3 Correct 263 ms 8280 KB Output is correct
4 Correct 398 ms 8528 KB Output is correct
5 Correct 336 ms 8284 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 280 ms 8280 KB Output is correct
2 Correct 439 ms 8284 KB Output is correct
3 Correct 272 ms 8284 KB Output is correct
4 Correct 370 ms 8284 KB Output is correct
5 Correct 340 ms 8528 KB Output is correct