Submission #623069

# Submission time Handle Problem Language Result Execution time Memory
623069 2022-08-05T07:02:01 Z 54skyxenon Mobile (BOI12_mobile) C++17
8 / 100
610 ms 15976 KB
// https://oj.uz/problem/view/BOI12_mobile

#include <bits/stdc++.h>
using namespace std;

#define EPS 0.001

int n, l;
vector<double> X, Y;

bool ok(double radius) {
    double range = 0.0;
    
    for (int i = 0; i < n; i++) {
        double x1 = X[i], y1 = Y[i];
        double term = (radius * radius) - (Y[i] * Y[i]);

        if (term >= 0) {
            double term_sqrt = sqrt(term);
            double range_l = X[i] - term_sqrt;
            double range_r = X[i] + term_sqrt;
            
            if (range_l <= range) {
                range = max(range, range_r);
            }
        }

        if (range >= l) {
            return false;
        }
    }
        
    return true;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> n >> l;

    X.resize(n);
    Y.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> X[i] >> Y[i];
    }

    double lo = 0.0;
    double hi = l;

    while (lo + EPS < hi) {
        double mid = (lo + hi) / 2;

        if (!ok(mid)) {
            hi = mid;
        }
        else {
            lo = mid;
        }
    }

    cout << lo << endl;
}

Compilation message

mobile.cpp: In function 'bool ok(double)':
mobile.cpp:15:16: warning: unused variable 'x1' [-Wunused-variable]
   15 |         double x1 = X[i], y1 = Y[i];
      |                ^~
mobile.cpp:15:27: warning: unused variable 'y1' [-Wunused-variable]
   15 |         double x1 = X[i], y1 = Y[i];
      |                           ^~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
# 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 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 360 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Incorrect 3 ms 340 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 340 KB Output is correct
2 Incorrect 3 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 340 KB Output is correct
2 Incorrect 3 ms 284 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 340 KB Output is correct
2 Incorrect 4 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 50 ms 1492 KB Output is correct
2 Incorrect 49 ms 1508 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 35 ms 1492 KB Output is correct
2 Correct 37 ms 1420 KB Output is correct
3 Incorrect 39 ms 1492 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 40 ms 1620 KB Output is correct
2 Incorrect 45 ms 1620 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 71 ms 1888 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 61 ms 1888 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 306 ms 8148 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 303 ms 8268 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 291 ms 9700 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 352 ms 9704 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 337 ms 11276 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 415 ms 11292 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 407 ms 12840 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 610 ms 12840 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 522 ms 15972 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 587 ms 15976 KB Output isn't correct
2 Halted 0 ms 0 KB -