Submission #888108

# Submission time Handle Problem Language Result Execution time Memory
888108 2023-12-16T03:50:57 Z eysbutno Mobile (BOI12_mobile) C++11
0 / 100
1000 ms 59068 KB
#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

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 time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Incorrect 3 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 680 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 32 ms 920 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 32 ms 1052 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 9 ms 924 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 152 ms 9372 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 472 ms 7840 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 387 ms 8508 KB Output is correct
2 Incorrect 537 ms 8444 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 516 ms 8484 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 428 ms 8928 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1066 ms 36928 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1054 ms 37316 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1053 ms 55740 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1031 ms 55308 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1032 ms 56480 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1010 ms 56004 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1036 ms 57364 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1046 ms 57856 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1050 ms 59068 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1022 ms 57872 KB Time limit exceeded
2 Halted 0 ms 0 KB -