Submission #464003

# Submission time Handle Problem Language Result Execution time Memory
464003 2021-08-12T07:07:57 Z dqk Mobile (BOI12_mobile) C++17
0 / 100
1000 ms 111736 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-6) {
        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 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 11 ms 680 KB Output is correct
2 Incorrect 22 ms 644 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 21 ms 972 KB Output is correct
2 Incorrect 18 ms 960 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 16 ms 956 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 24 ms 964 KB Output is correct
2 Incorrect 16 ms 964 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 314 ms 10004 KB Output is correct
2 Incorrect 295 ms 10216 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 312 ms 10368 KB Output is correct
2 Correct 265 ms 9600 KB Output is correct
3 Incorrect 282 ms 10460 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 678 ms 12104 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 422 ms 12096 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 407 ms 12068 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1084 ms 56056 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1090 ms 56044 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1088 ms 78352 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1084 ms 78272 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1089 ms 94460 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1076 ms 86820 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1088 ms 94660 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1081 ms 94668 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1092 ms 111724 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1089 ms 111736 KB Time limit exceeded
2 Halted 0 ms 0 KB -