Submission #930450

# Submission time Handle Problem Language Result Execution time Memory
930450 2024-02-19T17:54:51 Z sleepntsheep Mobile (BOI12_mobile) C++17
0 / 100
1000 ms 8228 KB
#include <stdio.h>
#include <math.h>
#define N 1000000

int n, L, x[N], y[N];

int ok(long double m)
{
    m *= m;
    long double li = 0, ri = L;
    for (int i = 0; i < n; ++i)
    {
        long double lbnd = INFINITY, rbnd = -INFINITY;

        auto f = [&](long double x_p)
        {
            return x_p*x_p - 2*x_p*x[i];
        };

        auto A = m - x[i] * x[i] - y[i] * y[i];

        if (f(x[i]) > A) return 0;

        long double l = -1e9, r = x[i];
        for (int iter = 100; iter--;)
        {
            long double mm = (l+r)/2;
            if (f(mm) <= A) r = mm, lbnd = mm;
            else l = mm;
        }

        l = x[i], r = 1e9;
        for (int iter = 100; iter--;)
        {
            long double mm = (l+r)/2;
            if (f(mm) <= A) r = mm, lbnd = mm;
            else r = mm;
        }
        if (lbnd > li) li = lbnd;
        if (ri > rbnd) ri = rbnd;
    }
    if (li > ri) return 0;
    return 1;
}

int main()
{
    scanf("%d%d", &n, &L);
    for (int i = 0; i < n; ++i) scanf("%d%d", x+i, y+i);

    long double l = 0, r = 2e9;
    for (int iter = 200; iter--;)
    {
        long double m = (l+r)/2;
        if (ok(m)) r = m;
        else l = m;
    }

    printf("%.6Lf", r);


    return 0;
}

Compilation message

mobile.cpp: In function 'int main()':
mobile.cpp:48:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   48 |     scanf("%d%d", &n, &L);
      |     ~~~~~^~~~~~~~~~~~~~~~
mobile.cpp:49:38: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   49 |     for (int i = 0; i < n; ++i) scanf("%d%d", x+i, y+i);
      |                                 ~~~~~^~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 449 ms 2464 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 820 ms 2468 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 822 ms 2640 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 816 ms 2468 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1050 ms 2532 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1068 ms 2744 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1081 ms 2652 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1051 ms 2652 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1036 ms 2640 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1044 ms 7644 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1079 ms 7504 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1040 ms 7464 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1055 ms 7788 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1053 ms 7508 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1030 ms 7504 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1020 ms 7504 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1060 ms 7508 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1091 ms 8096 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1061 ms 8228 KB Time limit exceeded
2 Halted 0 ms 0 KB -