Submission #873849

# Submission time Handle Problem Language Result Execution time Memory
873849 2023-11-16T01:15:44 Z tvladm2009 Mobile (BOI12_mobile) C++17
12 / 100
243 ms 16468 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(3);

    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;
        a[i].second = std::abs(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]));
    }
    answer = (ld) ((ld) ((ld) answer * (int) 1e3) / (int) 1e3);
    std::cout << answer << "\n";
    return 0;
}

Compilation message

mobile.cpp: In function 'int main()':
mobile.cpp:51: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]
   51 |     for (int i = 1; i < st.size() - 1; i++) {
      |                     ~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 600 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Incorrect 1 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Incorrect 1 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Incorrect 1 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 12 ms 1112 KB Output is correct
2 Incorrect 12 ms 856 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 11 ms 860 KB Output is correct
2 Correct 12 ms 860 KB Output is correct
3 Incorrect 13 ms 860 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 21 ms 1880 KB Output is correct
2 Incorrect 13 ms 860 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 1116 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 20 ms 1768 KB Output is correct
2 Incorrect 15 ms 1116 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 122 ms 8456 KB Output is correct
2 Correct 76 ms 4188 KB Output is correct
3 Correct 74 ms 4360 KB Output is correct
4 Incorrect 97 ms 4188 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 77 ms 4184 KB Output is correct
2 Correct 84 ms 4692 KB Output is correct
3 Incorrect 71 ms 4948 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 141 ms 10068 KB Output is correct
2 Correct 90 ms 4956 KB Output is correct
3 Correct 90 ms 5144 KB Output is correct
4 Incorrect 110 ms 4952 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 94 ms 4956 KB Output is correct
2 Correct 100 ms 5396 KB Output is correct
3 Correct 82 ms 5456 KB Output is correct
4 Incorrect 111 ms 4952 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 166 ms 11600 KB Output is correct
2 Correct 115 ms 5724 KB Output is correct
3 Correct 110 ms 5724 KB Output is correct
4 Incorrect 130 ms 5724 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 108 ms 5720 KB Output is correct
2 Correct 124 ms 6180 KB Output is correct
3 Incorrect 102 ms 6736 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 189 ms 13104 KB Output is correct
2 Correct 127 ms 6704 KB Output is correct
3 Correct 118 ms 6488 KB Output is correct
4 Incorrect 148 ms 6488 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 128 ms 6488 KB Output is correct
2 Correct 136 ms 7248 KB Output is correct
3 Incorrect 112 ms 7504 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 243 ms 16356 KB Output is correct
2 Correct 154 ms 8280 KB Output is correct
3 Runtime error 156 ms 16468 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 165 ms 8284 KB Output is correct
2 Correct 165 ms 8788 KB Output is correct
3 Incorrect 149 ms 9552 KB Output isn't correct
4 Halted 0 ms 0 KB -