Submission #903921

# Submission time Handle Problem Language Result Execution time Memory
903921 2024-01-11T14:38:53 Z tz74 Mobile (BOI12_mobile) C++17
8 / 100
839 ms 18868 KB
#include <iostream>
#include <vector>
#include <iomanip>
#include <ctgmath>

using namespace std;

using i64 = long long;
using f64 = double;

i64 N;
f64 L;
vector<pair<i64, i64> > towers;

f64 sq(f64 in) {
    return in * in;
}

bool contiguous(f64 R) {
    f64 rightmost = 0;

    for (int i = 0; i < N; i++) {
        f64 x = towers[i].first;
        f64 y = towers[i].second;
        f64 d = sq(2.0 * x) - 4.0 * (sq(x) + sq(y) - sq(R));

        if (d > 0) {
            f64 x1 = (2.0 * x - sqrt(d)) / 2;
            f64 x2 = (2.0 * x + sqrt(d)) / 2;

            // printf("i: %d, x1: %lf, x2: %lf\n", i, x1, x2);

            if (x1 < rightmost) {
                rightmost = max(rightmost, x2);
            }
        }
    }

    // printf("leftmost: %lf, rightmost: %lf\n", leftmost, rightmost);
    return rightmost >= L;
}

int main(void) {
    cin >> N >> L;
    for (int i = 0; i < N; i++) {
        pair<i64, i64> p;
        cin >> p.first >> p.second;
        towers.push_back(p);
    }

    // printf("contiguous: %d\n", contiguous(7.8102));
    // return 0;

    f64 lo = 1.0;
    f64 hi = 1.5e9;

    while (hi - lo > 1e-4) {
        f64 mid = (hi + lo) / 2;

        // we want the largest value where it's not contiguous
        if (contiguous(mid)) {
            hi = mid;
        } else {
            lo = mid;
        }
    }

    cout << lo << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 356 KB Output is correct
3 Correct 0 ms 360 KB Output is correct
4 Correct 0 ms 360 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 360 KB Output is correct
2 Correct 1 ms 452 KB Output is correct
3 Correct 1 ms 360 KB Output is correct
4 Correct 0 ms 444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 360 KB Output is correct
2 Correct 2 ms 360 KB Output is correct
3 Correct 1 ms 360 KB Output is correct
4 Incorrect 2 ms 360 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 616 KB Output is correct
2 Incorrect 3 ms 616 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 600 KB Output is correct
2 Incorrect 4 ms 608 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 856 KB Output is correct
2 Incorrect 4 ms 768 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 51 ms 2512 KB Output is correct
2 Incorrect 48 ms 3524 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 58 ms 2508 KB Output is correct
2 Correct 39 ms 3348 KB Output is correct
3 Incorrect 52 ms 3524 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 44 ms 2508 KB Output is correct
2 Incorrect 63 ms 2476 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 66 ms 2504 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 75 ms 2512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 268 ms 10040 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 325 ms 10396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 385 ms 17016 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 433 ms 17072 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 364 ms 17640 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 465 ms 17384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 421 ms 17836 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 528 ms 18536 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 520 ms 18868 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 839 ms 18436 KB Output isn't correct
2 Halted 0 ms 0 KB -