Submission #493278

# Submission time Handle Problem Language Result Execution time Memory
493278 2021-12-10T16:23:42 Z CraniXort Mobile (BOI12_mobile) C++17
100 / 100
902 ms 50936 KB
#include <bits/stdc++.h>

#define maxn 100005
long double delta = 0.000001;

#define fin std::cin
#define fout std::cout

std::vector <std::pair <long double, long double>> v;


bool check(long double lenght, long double l) {
    long double left = 0, right = 0;
    for(auto i: v) {
        if(l*l - i.second * i.second < 0)
            continue;
        long double r = sqrtl(l*l - i.second * i.second);

        if(i.first - r <= right)
            right = std::max(right, i.first + r);
    }
    if(right >= lenght)
        return true;
    return false;
}

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    std::cout.tie(NULL);

    int n;
    long double lenght;
    fin >> n >> lenght;
    v.resize(n);

    for(int i = 0; i < n; i ++)
        fin >> v[i].first >> v[i].second;

    long double left = 0, right = 2e9, mid, ans = 0;

    while(right - left >= 0.00001) {
        mid = (left + right) / 2;

        if(check(lenght, mid) == true) {
            ans = mid;
            right = mid;
        }
        else
            left = mid;
    }

    fout << std::setprecision(3) << std::fixed;
    fout << ans << '\n';
   
    return 0;
}

Compilation message

mobile.cpp: In function 'bool check(long double, long double)':
mobile.cpp:13:17: warning: unused variable 'left' [-Wunused-variable]
   13 |     long double left = 0, right = 0;
      |                 ^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
3 Correct 2 ms 332 KB Output is correct
4 Correct 3 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 460 KB Output is correct
2 Correct 6 ms 460 KB Output is correct
3 Correct 4 ms 460 KB Output is correct
4 Correct 4 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 460 KB Output is correct
2 Correct 5 ms 460 KB Output is correct
3 Correct 4 ms 460 KB Output is correct
4 Correct 4 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 460 KB Output is correct
2 Correct 7 ms 460 KB Output is correct
3 Correct 4 ms 460 KB Output is correct
4 Correct 5 ms 460 KB Output is correct
5 Correct 5 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 79 ms 2636 KB Output is correct
2 Correct 73 ms 2636 KB Output is correct
3 Correct 37 ms 2508 KB Output is correct
4 Correct 54 ms 3832 KB Output is correct
5 Correct 29 ms 2252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 51 ms 2764 KB Output is correct
2 Correct 54 ms 2508 KB Output is correct
3 Correct 75 ms 2764 KB Output is correct
4 Correct 55 ms 3940 KB Output is correct
5 Correct 61 ms 4436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 57 ms 3020 KB Output is correct
2 Correct 64 ms 2892 KB Output is correct
3 Correct 74 ms 3908 KB Output is correct
4 Correct 85 ms 5344 KB Output is correct
5 Correct 59 ms 3988 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 79 ms 3404 KB Output is correct
2 Correct 80 ms 4840 KB Output is correct
3 Correct 71 ms 4468 KB Output is correct
4 Correct 83 ms 5352 KB Output is correct
5 Correct 67 ms 4596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 81 ms 3404 KB Output is correct
2 Correct 76 ms 4848 KB Output is correct
3 Correct 71 ms 4464 KB Output is correct
4 Correct 83 ms 5360 KB Output is correct
5 Correct 73 ms 4720 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 380 ms 15948 KB Output is correct
2 Correct 411 ms 23636 KB Output is correct
3 Correct 405 ms 23120 KB Output is correct
4 Correct 391 ms 25428 KB Output is correct
5 Correct 357 ms 22736 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 411 ms 15948 KB Output is correct
2 Correct 475 ms 22480 KB Output is correct
3 Correct 363 ms 21604 KB Output is correct
4 Correct 433 ms 25168 KB Output is correct
5 Correct 356 ms 23260 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 475 ms 19020 KB Output is correct
2 Correct 565 ms 28304 KB Output is correct
3 Correct 530 ms 27716 KB Output is correct
4 Correct 500 ms 30860 KB Output is correct
5 Correct 414 ms 27020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 538 ms 19020 KB Output is correct
2 Correct 553 ms 26892 KB Output is correct
3 Correct 431 ms 25868 KB Output is correct
4 Correct 481 ms 30736 KB Output is correct
5 Correct 470 ms 27788 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 535 ms 22220 KB Output is correct
2 Correct 634 ms 32968 KB Output is correct
3 Correct 570 ms 32332 KB Output is correct
4 Correct 537 ms 35660 KB Output is correct
5 Correct 514 ms 31180 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 576 ms 22220 KB Output is correct
2 Correct 642 ms 31432 KB Output is correct
3 Correct 510 ms 30660 KB Output is correct
4 Correct 590 ms 35528 KB Output is correct
5 Correct 502 ms 32332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 578 ms 25284 KB Output is correct
2 Correct 667 ms 37640 KB Output is correct
3 Correct 664 ms 36872 KB Output is correct
4 Correct 694 ms 40968 KB Output is correct
5 Correct 606 ms 36484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 718 ms 25420 KB Output is correct
2 Correct 737 ms 35908 KB Output is correct
3 Correct 648 ms 34816 KB Output is correct
4 Correct 633 ms 40716 KB Output is correct
5 Correct 592 ms 36868 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 759 ms 31720 KB Output is correct
2 Correct 840 ms 47092 KB Output is correct
3 Correct 838 ms 46072 KB Output is correct
4 Correct 786 ms 50676 KB Output is correct
5 Correct 725 ms 45176 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 844 ms 31624 KB Output is correct
2 Correct 902 ms 44788 KB Output is correct
3 Correct 746 ms 43896 KB Output is correct
4 Correct 840 ms 50936 KB Output is correct
5 Correct 704 ms 46332 KB Output is correct