Submission #464002

# Submission time Handle Problem Language Result Execution time Memory
464002 2021-08-12T07:05:51 Z dqk Mobile (BOI12_mobile) C++17
0 / 100
1000 ms 126368 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 = L * sqrt(2);
    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 1 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 2 ms 460 KB Output is correct
2 Incorrect 10 ms 664 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 716 KB Output is correct
2 Incorrect 11 ms 1036 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 764 KB Output is correct
2 Incorrect 10 ms 984 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 12 ms 972 KB Output is correct
2 Incorrect 9 ms 984 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 152 ms 10220 KB Output is correct
2 Incorrect 165 ms 11328 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 45 ms 7804 KB Output is correct
2 Correct 42 ms 7540 KB Output is correct
3 Incorrect 51 ms 8288 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 515 ms 11548 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 381 ms 14364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 311 ms 13140 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1086 ms 59468 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1030 ms 63304 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1062 ms 83544 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1085 ms 88312 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1094 ms 95428 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1081 ms 100840 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1093 ms 107112 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1083 ms 113468 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1093 ms 118772 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1091 ms 126368 KB Time limit exceeded
2 Halted 0 ms 0 KB -