Submission #654439

# Submission time Handle Problem Language Result Execution time Memory
654439 2022-10-31T09:59:02 Z yhussain11 Mobile (BOI12_mobile) C++17
100 / 100
495 ms 28216 KB
#include<bits/stdc++.h>

#define unless(x) if (!(x))
#define pb push_back
#define eb emplace_back
/* #define f first */
/* #define s second */
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define mem(x, y) memset(x, y, sizeof(x))
#define sz(x) ((int) (x).size())
#define popcnt __builtin_popcntll

using namespace std;
using ll = long long;
using ld = long double;
using pi = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vpi = vector<pi>;
using vpll = vector<pll>;
using vvi = vector<vector<int>>;

// *INDENT-OFF*
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template<typename T, typename V> void __print(const pair<T, V> &x) { cerr << '{'; __print(x.first); cerr << ", "; __print(x.second); cerr << '}'; }
template<size_t I = 0, typename... Tp> void __print_tup(const tuple<Tp...>& t) { cerr << get<I>(t); if constexpr(I < sizeof...(Tp) - 1) { cerr << ", "; __print_tup<I+1>(t); } }
template<typename... Tp> void __print(const tuple<Tp...>& t) { cerr << '{'; __print_tup(t); cerr << '}'; }
/* template<typename... Args> void __print(const tuple<Args...>& t) { cerr << '{'; apply([](auto&&... args) { ((cout << args << ','), ...); }, t); cerr << '}'; } */
template<typename T> void __print(const T &x) { int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? ", " : ""), __print(i); cerr << "}"; }
void _print() { cerr << "]\n"; }
template <typename T, typename... V> void _print(T t, V... v) { __print(t); if (sizeof...(v)) cerr << ", "; _print(v...); }
template<typename T> T fdiv(T x, T y) { T q = x / y; T r = x % y; if ((r != 0) && ((r < 0) != (y < 0))) --q; return q; }
template<typename T> T cdiv(T x, T y) { return x / y + ((x % y != 0) ? !((x > 0) ^ (y > 0)) : 0); }
namespace std { template<class Fun> class y_combinator_result { Fun fun_; public: template<class T> explicit y_combinator_result(T &&fun): fun_(std::forward<T>(fun)) {} template<class ...Args> decltype(auto) operator()(Args &&...args) { return fun_(std::ref(*this), std::forward<Args>(args)...); } }; template<class Fun> decltype(auto) yy(Fun &&fun) { return y_combinator_result<std::decay_t<Fun>>(std::forward<Fun>(fun)); } }
const string yes = "Yes";
const string no = "No";
const int infs = 0x3f;
const int infb = 0x3f3f3f3f;
#ifdef LOCAL
#define dbg(x...) cerr << "\e[1;31m"<<__func__<<":"<<__LINE__<<" [" << #x << "] = ["; _print(x); cerr << "\e[0m";
#else
#define dbg(x...)
#endif
// *INDENT-ON*

// YOU ARE ACTUALLY **SUPPOSED** TO READ THE FOLLOWING.
// Read the problem. Now Re-read the problem.
// Observe each constraint. Please do this. Notice each and every constraint.
// You have made many mistakes because you didn't read the constraint well enough.
// You are probably solving a harder version of the given problem.
// DO NOT OVERSOLVE.
// Do not look ahead for next problem. Solve the current problem.
// Do not look at standings.
// check overflow/underflow
// Declare double values as long double or ld (NEVER double, because of precision issues)
// Open the damn Excel Sheet!!!!

// BE EXTRA EXTRA EXTRA CAREFUL WHILE MULTIPLYING!!!!! <- SEE THIS!!! SEE THIS!!!

void solve() {
    int n, l;
    cin >> n >> l;
    vpll v(n);
    for (auto &[a, b] : v) {
        cin >> a >> b;
    }
    ld epsilon = 1.0L / 1e4;
    ld lo = 0, hi = 4e9;
    while (hi - lo > epsilon) {
        ld mid = (lo + hi) / 2;
        ld curr = 0;
        for (auto [a, b] : v) {
            if (mid >= abs(b)) {
                ld D = mid * mid - b * b;
                ld lefti = a - sqrt(D);
                ld righti = a + sqrt(D);
                if (lefti <= curr) ckmax(curr, righti);
            }
        }
        if (curr >= l) {
            hi = mid;
        } else {
            lo = mid;
        }
    }
    cout << fixed << setprecision(6) << lo << '\n';
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    /* cin >> t; */
    while (t--) {
        solve();
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 340 KB Output is correct
2 Correct 3 ms 340 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 3 ms 468 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 2 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 340 KB Output is correct
2 Correct 3 ms 340 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 34 ms 1492 KB Output is correct
2 Correct 36 ms 2508 KB Output is correct
3 Correct 21 ms 1748 KB Output is correct
4 Correct 27 ms 2628 KB Output is correct
5 Correct 27 ms 1492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 27 ms 1492 KB Output is correct
2 Correct 23 ms 2188 KB Output is correct
3 Correct 26 ms 2504 KB Output is correct
4 Correct 26 ms 2772 KB Output is correct
5 Correct 29 ms 3076 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 37 ms 1620 KB Output is correct
2 Correct 36 ms 1620 KB Output is correct
3 Correct 31 ms 1620 KB Output is correct
4 Correct 31 ms 1876 KB Output is correct
5 Correct 32 ms 2612 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 46 ms 1876 KB Output is correct
2 Correct 45 ms 1876 KB Output is correct
3 Correct 39 ms 1876 KB Output is correct
4 Correct 32 ms 1876 KB Output is correct
5 Correct 41 ms 1876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 43 ms 1876 KB Output is correct
2 Correct 42 ms 1876 KB Output is correct
3 Correct 42 ms 1876 KB Output is correct
4 Correct 34 ms 1876 KB Output is correct
5 Correct 35 ms 1876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 200 ms 8148 KB Output is correct
2 Correct 210 ms 8148 KB Output is correct
3 Correct 290 ms 8148 KB Output is correct
4 Correct 151 ms 8148 KB Output is correct
5 Correct 158 ms 14920 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 211 ms 8148 KB Output is correct
2 Correct 290 ms 8148 KB Output is correct
3 Correct 191 ms 13896 KB Output is correct
4 Correct 155 ms 17500 KB Output is correct
5 Correct 170 ms 15432 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 285 ms 9700 KB Output is correct
2 Correct 254 ms 9684 KB Output is correct
3 Correct 280 ms 9684 KB Output is correct
4 Correct 189 ms 9684 KB Output is correct
5 Correct 205 ms 9684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 284 ms 9684 KB Output is correct
2 Correct 295 ms 9684 KB Output is correct
3 Correct 219 ms 9684 KB Output is correct
4 Correct 189 ms 9668 KB Output is correct
5 Correct 197 ms 18408 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 282 ms 11220 KB Output is correct
2 Correct 300 ms 11220 KB Output is correct
3 Correct 310 ms 11220 KB Output is correct
4 Correct 211 ms 11220 KB Output is correct
5 Correct 237 ms 20296 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 320 ms 11220 KB Output is correct
2 Correct 328 ms 11220 KB Output is correct
3 Correct 306 ms 11220 KB Output is correct
4 Correct 230 ms 11176 KB Output is correct
5 Correct 218 ms 11220 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 390 ms 12756 KB Output is correct
2 Correct 353 ms 12756 KB Output is correct
3 Correct 352 ms 12808 KB Output is correct
4 Correct 294 ms 12756 KB Output is correct
5 Correct 385 ms 12812 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 364 ms 12756 KB Output is correct
2 Correct 434 ms 12756 KB Output is correct
3 Correct 374 ms 22304 KB Output is correct
4 Correct 326 ms 28216 KB Output is correct
5 Correct 274 ms 24360 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 432 ms 15956 KB Output is correct
2 Correct 478 ms 15956 KB Output is correct
3 Correct 489 ms 16004 KB Output is correct
4 Correct 316 ms 15956 KB Output is correct
5 Correct 352 ms 15860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 445 ms 15956 KB Output is correct
2 Correct 495 ms 15956 KB Output is correct
3 Correct 391 ms 15956 KB Output is correct
4 Correct 319 ms 15928 KB Output is correct
5 Correct 317 ms 15956 KB Output is correct