Submission #873843

# Submission time Handle Problem Language Result Execution time Memory
873843 2023-11-16T00:35:35 Z tvladm2009 Mobile (BOI12_mobile) C++17
0 / 100
233 ms 31052 KB
#include <bits/stdc++.h>

using i64 = long long;
using ld = long double;

ld cross(std::pair<int, int> a, std::pair<int, int> b) {
    int x1 = a.first, x2 = b.first, y1 = a.second, y2 = b.second;
    return 1.0 * (1ll * x2 * x2 + y2 * y2 - 1ll * x1 * x1 - 1ll * y1 * y1) / (2.0 * (x2 - x1));
}

ld solve(ld s, ld e, std::pair<int, int> t) {
    return std::max(std::hypot(s - t.first, t.second), std::hypot(e - t.first, t.second));
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    std::cout << std::fixed << std::setprecision(10);

    int n, L;
    std::cin >> n >> L;
    std::vector<std::pair<int, int>> a(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i].first >> a[i].second;
    }
    std::sort(a.begin(), a.end());
    std::deque<std::pair<int, int>> st;
    for (int i = 0; i < n; i++) {
        int j = i;
        while (j < n && a[j].first == a[i].first) {
            j++;
        }
        while (st.size() >= 2 && cross(st[st.size() - 2], st.back()) > cross(st.back(), a[i])) {
            st.pop_back();
        }
        st.push_back(a[i]);
        i = j - 1;
    }

    ld answer = 0;
    while (st.size() >= 2 && cross(st[0], st[1]) < 0) {
        st.pop_front();
    }
    while (st.size() >= 2 && cross(st[st.size() - 2], st.back()) > L) {
        st.pop_back();
    }
    answer = std::max(answer, solve(0, cross(st[0], st[1]), st[0]));
    answer = std::max(answer, solve(cross(st[st.size() - 2], st.back()), L, st.back()));
    for (int i = 1; i < st.size() - 1; i++) {
        answer = std::max(answer, solve(cross(st[i - 1], st[i]), cross(st[i], st[i + 1]), st[i]));
    }
    std::cout << answer << "\n";
    return 0;
}

Compilation message

mobile.cpp: In function 'int main()':
mobile.cpp:50:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::deque<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |     for (int i = 1; i < st.size() - 1; i++) {
      |                     ~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 468 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 556 KB Output is correct
3 Correct 1 ms 532 KB Output is correct
4 Incorrect 1 ms 344 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 12 ms 1884 KB Output is correct
2 Incorrect 12 ms 1944 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 1624 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 21 ms 2396 KB Output is correct
2 Incorrect 13 ms 2140 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 2652 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 20 ms 3024 KB Output is correct
2 Incorrect 15 ms 2652 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 120 ms 12796 KB Output is correct
2 Correct 85 ms 12028 KB Output is correct
3 Correct 78 ms 11600 KB Output is correct
4 Incorrect 100 ms 13828 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 80 ms 12368 KB Output is correct
2 Correct 83 ms 11264 KB Output is correct
3 Incorrect 73 ms 10908 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 143 ms 15184 KB Output is correct
2 Correct 95 ms 14356 KB Output is correct
3 Correct 92 ms 13652 KB Output is correct
4 Incorrect 112 ms 17036 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 101 ms 15116 KB Output is correct
2 Correct 110 ms 13392 KB Output is correct
3 Correct 81 ms 12316 KB Output is correct
4 Incorrect 117 ms 16724 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 170 ms 17688 KB Output is correct
2 Correct 113 ms 16552 KB Output is correct
3 Correct 119 ms 15956 KB Output is correct
4 Incorrect 132 ms 19280 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 113 ms 17328 KB Output is correct
2 Correct 116 ms 15444 KB Output is correct
3 Incorrect 106 ms 15132 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 188 ms 20292 KB Output is correct
2 Correct 129 ms 18880 KB Output is correct
3 Correct 120 ms 18256 KB Output is correct
4 Incorrect 159 ms 22368 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 141 ms 19776 KB Output is correct
2 Correct 135 ms 17716 KB Output is correct
3 Incorrect 130 ms 17016 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 233 ms 24928 KB Output is correct
2 Correct 151 ms 23768 KB Output is correct
3 Runtime error 164 ms 31052 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 163 ms 24676 KB Output is correct
2 Correct 168 ms 21968 KB Output is correct
3 Incorrect 143 ms 21848 KB Output isn't correct
4 Halted 0 ms 0 KB -