Submission #729570

# Submission time Handle Problem Language Result Execution time Memory
729570 2023-04-24T09:15:13 Z PanosPask Mobile (BOI12_mobile) C++14
0 / 100
1000 ms 35160 KB
#include <bits/stdc++.h>

using namespace std;

typedef pair<long long, long long > pl;

int n, l;
vector<pl> transmitters;

bool distance_covers(double x)
{
    double latest_cover = 0;
    for (int i = 0; i < n && latest_cover < l; i++) {
        pl cur = transmitters[i];
        if (cur.second > x)
            continue;

        double k = sqrt(x * x - cur.second * cur.second);

        if (cur.first - k <= latest_cover)
            latest_cover = cur.first + k;
    }

    return latest_cover >= l;
}

int main(void)
{
    scanf("%d %d", &n, &l);
    transmitters.resize(n);
    for (int i = 0; i < n; i++)
        scanf("%lld %lld", &transmitters[i].first, &transmitters[i].second);

    double l = 0; //distance_covers(l) = false
    double r = 1; //distance_covers(r) = true
    while (!distance_covers(r)) {
        l = r;
        r *= 2;
    }

    for (int i = 0; i < 60; i++) {
        double mid = (l + r) / 2;
        if (distance_covers(mid))
            r = mid;
        else
            l = mid;
    }

    printf("%lf\n", r);
    return 0;
}

Compilation message

mobile.cpp: In function 'int main()':
mobile.cpp:29:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |     scanf("%d %d", &n, &l);
      |     ~~~~~^~~~~~~~~~~~~~~~~
mobile.cpp:32:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |         scanf("%lld %lld", &transmitters[i].first, &transmitters[i].second);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 308 KB Output is correct
2 Correct 2 ms 312 KB Output is correct
3 Incorrect 2 ms 224 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 424 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 340 KB Output is correct
2 Correct 3 ms 440 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Incorrect 6 ms 468 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 49 ms 2256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 37 ms 2256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 40 ms 2312 KB Output is correct
2 Correct 41 ms 2736 KB Output is correct
3 Correct 31 ms 2516 KB Output is correct
4 Incorrect 120 ms 3796 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 43 ms 3404 KB Output is correct
2 Correct 38 ms 3272 KB Output is correct
3 Correct 34 ms 2872 KB Output is correct
4 Incorrect 110 ms 3772 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 47 ms 3372 KB Output is correct
2 Correct 40 ms 3272 KB Output is correct
3 Correct 46 ms 2772 KB Output is correct
4 Incorrect 114 ms 3820 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 276 ms 12416 KB Output is correct
2 Correct 217 ms 15848 KB Output is correct
3 Correct 194 ms 15348 KB Output is correct
4 Incorrect 596 ms 17692 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 221 ms 16340 KB Output is correct
2 Incorrect 376 ms 14740 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 326 ms 14864 KB Output is correct
2 Correct 237 ms 18976 KB Output is correct
3 Correct 247 ms 18380 KB Output is correct
4 Incorrect 669 ms 21580 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 277 ms 19560 KB Output is correct
2 Incorrect 440 ms 17616 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 409 ms 17300 KB Output is correct
2 Correct 309 ms 22124 KB Output is correct
3 Correct 242 ms 21420 KB Output is correct
4 Incorrect 798 ms 24804 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 320 ms 22760 KB Output is correct
2 Incorrect 534 ms 20504 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 492 ms 19720 KB Output is correct
2 Correct 409 ms 25236 KB Output is correct
3 Correct 303 ms 24460 KB Output is correct
4 Incorrect 857 ms 28480 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 311 ms 26024 KB Output is correct
2 Incorrect 606 ms 23392 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 714 ms 24648 KB Output is correct
2 Correct 473 ms 31500 KB Output is correct
3 Correct 591 ms 30404 KB Output is correct
4 Execution timed out 1028 ms 35160 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 421 ms 32460 KB Output is correct
2 Incorrect 703 ms 29176 KB Output isn't correct
3 Halted 0 ms 0 KB -