Submission #464004

# Submission time Handle Problem Language Result Execution time Memory
464004 2021-08-12T07:08:59 Z dqk Mobile (BOI12_mobile) C++17
0 / 100
1000 ms 111764 KB
#include <bits/stdc++.h>

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n;
    double L;
    std::cin >> n >> L;
    std::vector<std::vector<int>> p(n, std::vector<int>(2, 0));
    for (int i = 0; i < n; ++i) {
        std::cin >> p[i][0] >> p[i][1];
    }
    double lo = 0, hi = 1e10;
    while(hi - lo > 1e-4) {
        double mi = (lo + hi) / 2;
        std::vector<std::vector<double>> u;
        for (int i = 0; i < n; ++i) {
            double h = abs(p[i][1]);
            if (h > mi)
                continue;
            double lf = p[i][0] - sqrt(mi * mi - h * h);
            double rt = p[i][0] + sqrt(mi * mi - h * h);
            if (rt < 0 || lf > L)
                continue;
            lf = std::max(lf, 0.0);
            rt = std::min(rt, L);
            u.push_back({lf, rt});
        }
        sort(u.begin(), u.end());
        double lf, rt;
        lf = rt = -1;
        bool ok = true;
        for (int i = 0; i < u.size() && ok; ++i) {
            if (i == 0) {
                lf = u[i][0];
                rt = u[i][1];
            }
            else {
                if (u[i][0] > rt)
                    ok = false;
                rt = std::max(rt, u[i][1]);
            }
        }
        if (lf != 0 && rt != L)
            ok = false;
        if (ok) {
            hi = mi;
        }
        else {
            lo = mi;
        }
    }
    std::cout << lo << "\n";
    return 0;
}

Compilation message

mobile.cpp: In function 'int main()':
mobile.cpp:33:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<double> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |         for (int i = 0; i < u.size() && ok; ++i) {
      |                         ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 332 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 12 ms 680 KB Output is correct
2 Incorrect 15 ms 648 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 19 ms 964 KB Output is correct
2 Incorrect 19 ms 956 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 19 ms 956 KB Output is correct
2 Incorrect 16 ms 960 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 21 ms 964 KB Output is correct
2 Incorrect 15 ms 964 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 305 ms 10060 KB Output is correct
2 Incorrect 288 ms 10212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 311 ms 10324 KB Output is correct
2 Correct 248 ms 9608 KB Output is correct
3 Incorrect 250 ms 10612 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 585 ms 12108 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 429 ms 12024 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 373 ms 12096 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1096 ms 56040 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1098 ms 56040 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1098 ms 78244 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1080 ms 78180 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1094 ms 94468 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1085 ms 86820 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1098 ms 94672 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1065 ms 94724 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1087 ms 111760 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1098 ms 111764 KB Time limit exceeded
2 Halted 0 ms 0 KB -