Submission #623089

# Submission time Handle Problem Language Result Execution time Memory
623089 2022-08-05T07:15:34 Z 54skyxenon Mobile (BOI12_mobile) C++17
100 / 100
601 ms 16076 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;
    
    for (int i = 0; i < n; 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<double>(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 << fixed << setprecision(4) << lo << endl;
}
# 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 0 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 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 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 3 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 340 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 3 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 3 ms 340 KB Output is correct
5 Correct 3 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 43 ms 1492 KB Output is correct
2 Correct 42 ms 1476 KB Output is correct
3 Correct 23 ms 1108 KB Output is correct
4 Correct 39 ms 1492 KB Output is correct
5 Correct 18 ms 1108 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 1536 KB Output is correct
2 Correct 31 ms 1416 KB Output is correct
3 Correct 41 ms 1492 KB Output is correct
4 Correct 42 ms 1492 KB Output is correct
5 Correct 60 ms 1620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 49 ms 1620 KB Output is correct
2 Correct 47 ms 1620 KB Output is correct
3 Correct 37 ms 1620 KB Output is correct
4 Correct 66 ms 1880 KB Output is correct
5 Correct 36 ms 1620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 59 ms 1880 KB Output is correct
2 Correct 64 ms 1876 KB Output is correct
3 Correct 50 ms 1876 KB Output is correct
4 Correct 62 ms 1876 KB Output is correct
5 Correct 45 ms 1876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 58 ms 1884 KB Output is correct
2 Correct 49 ms 1876 KB Output is correct
3 Correct 55 ms 1876 KB Output is correct
4 Correct 66 ms 1888 KB Output is correct
5 Correct 50 ms 1892 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 236 ms 8148 KB Output is correct
2 Correct 257 ms 8148 KB Output is correct
3 Correct 283 ms 8148 KB Output is correct
4 Correct 287 ms 8148 KB Output is correct
5 Correct 257 ms 8148 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 281 ms 8268 KB Output is correct
2 Correct 337 ms 8148 KB Output is correct
3 Correct 226 ms 8148 KB Output is correct
4 Correct 298 ms 8148 KB Output is correct
5 Correct 256 ms 8148 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 289 ms 9708 KB Output is correct
2 Correct 315 ms 9708 KB Output is correct
3 Correct 313 ms 9712 KB Output is correct
4 Correct 356 ms 9684 KB Output is correct
5 Correct 306 ms 9704 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 380 ms 9712 KB Output is correct
2 Correct 401 ms 9708 KB Output is correct
3 Correct 257 ms 9704 KB Output is correct
4 Correct 368 ms 9700 KB Output is correct
5 Correct 304 ms 9712 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 342 ms 11276 KB Output is correct
2 Correct 377 ms 11284 KB Output is correct
3 Correct 371 ms 11276 KB Output is correct
4 Correct 417 ms 11276 KB Output is correct
5 Correct 343 ms 11276 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 406 ms 11276 KB Output is correct
2 Correct 456 ms 11276 KB Output is correct
3 Correct 310 ms 11280 KB Output is correct
4 Correct 431 ms 11276 KB Output is correct
5 Correct 340 ms 11276 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 392 ms 12840 KB Output is correct
2 Correct 421 ms 12756 KB Output is correct
3 Correct 413 ms 12836 KB Output is correct
4 Correct 488 ms 12836 KB Output is correct
5 Correct 390 ms 12840 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 446 ms 12836 KB Output is correct
2 Correct 483 ms 12880 KB Output is correct
3 Correct 345 ms 12836 KB Output is correct
4 Correct 476 ms 12844 KB Output is correct
5 Correct 420 ms 12836 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 523 ms 15972 KB Output is correct
2 Correct 553 ms 16076 KB Output is correct
3 Correct 513 ms 15972 KB Output is correct
4 Correct 580 ms 15976 KB Output is correct
5 Correct 503 ms 15976 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 594 ms 15976 KB Output is correct
2 Correct 590 ms 15976 KB Output is correct
3 Correct 466 ms 15976 KB Output is correct
4 Correct 601 ms 16076 KB Output is correct
5 Correct 502 ms 15976 KB Output is correct