Submission #930446

# Submission time Handle Problem Language Result Execution time Memory
930446 2024-02-19T17:43:19 Z sleepntsheep Mobile (BOI12_mobile) C++17
0 / 100
1000 ms 8272 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 = -INFINITY, ri = INFINITY;
    for (int i = 0; i < n; ++i)
    {
        long double a = x[i];
        long double lbnd, rbnd;

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

        l = a, r = 1e9;
        for (int iter = 100; iter--;)
        {
            long double mm = (l+r)/2;
            if (mm*mm - 2*mm*x[i] <= m - x[i] * x[i] - y[i] * y[i])
                l = mm, rbnd = 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:42:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 |     scanf("%d%d", &n, &L);
      |     ~~~~~^~~~~~~~~~~~~~~~
mobile.cpp:43:38: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   43 |     for (int i = 0; i < n; ++i) scanf("%d%d", x+i, y+i);
      |                                 ~~~~~^~~~~~~~~~~~~~~~~~
mobile.cpp: In function 'int ok(long double)':
mobile.cpp:34:9: warning: 'rbnd' may be used uninitialized in this function [-Wmaybe-uninitialized]
   34 |         if (ri > rbnd) ri = rbnd;
      |         ^~
mobile.cpp:33:9: warning: 'lbnd' may be used uninitialized in this function [-Wmaybe-uninitialized]
   33 |         if (lbnd > li) li = lbnd;
      |         ^~
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 2392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 55 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1066 ms 2464 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1042 ms 2396 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1022 ms 2392 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1061 ms 2396 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1046 ms 2652 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1045 ms 2652 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1064 ms 2652 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1016 ms 2648 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1053 ms 2652 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1049 ms 7504 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1058 ms 7508 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1069 ms 7508 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1042 ms 7848 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1029 ms 7504 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1055 ms 7552 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1051 ms 7508 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1056 ms 7508 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1037 ms 8204 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1027 ms 8272 KB Time limit exceeded
2 Halted 0 ms 0 KB -