답안 #1098007

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1098007 2024-10-08T19:33:52 Z 0x34c Mobile (BOI12_mobile) C++17
95 / 100
549 ms 131072 KB
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define endl '\n'
#define int ll
#define ld long double
#define pdd pair<ld, ld>

using namespace std;

int dist2(pii a, pii b)
{
    return (a.first - b.first) * (a.first - b.first) + (a.second - b.second) * (a.second - b.second);
}

ld dist(pii a, ld x)
{
    return sqrt((((ld)a.first) - x) * (((ld)a.first) - x) + (ld)(a.second * a.second));
}

const int INF2 = 1e12;
const int INF = 1e9 + 1;
ld eps = 1e-4;

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int N, L;
    cin >> N >> L;

    vector<pii> inp(N);
    map<int, int> closest;
    for (int i = 0; i < N; i++)
    {
        int x, y;
        cin >> x >> y;

        inp[i] = {x, y};

        if (!closest.count(x))
            closest[x] = y;
        else
            closest[x] = (abs(closest[x]) > abs(y) ? y : closest[x]);
    }

    vector<pii> pts;
    for (pii p : closest)
        pts.push_back(p);

    N = pts.size();

    auto calc_bp = [&](int idx1, int idx2)
    {
        ld x1 = pts[idx1].first, y1 = pts[idx1].second;
        ld x2 = pts[idx2].first, y2 = pts[idx2].second;

        return ((ld)0.5) * (x1 + x2 + (y1 * y1 - y2 * y2) / (x1 - x2));
    };

    stack<int> stk;
    stk.push(0);
    vector<ld> dists, bps;
    for (int i = 1; i < N; i++)
    {
        ld bp = calc_bp(stk.top(), i);

        while (!bps.empty() && bps.back() > bp)
        {
            bps.pop_back();
            stk.pop();
            dists.pop_back();
            bp = calc_bp(stk.top(), i);
        }

        bps.push_back(bp);
        dists.push_back(dist(pts[i], bp));
        stk.push(i);
    }

    ld mx_dist = 0;
    for (int i = 0; i < bps.size(); i++)
    {
        if (bps[i] < 0 || bps[i] > L)
            continue;
        mx_dist = max(mx_dist, dists[i]);
    }

    ld mn_start = INF2, mn_end = INF2;
    for (int i = 0; i < N; i++)
    {
        mn_start = min(mn_start, dist(pts[i], 0));
        mn_end = min(mn_end, dist(pts[i], L));
    }

    mx_dist = max({mx_dist, mn_start, mn_end});
    cout << setprecision(4) << fixed << mx_dist << endl;
}

Compilation message

mobile.cpp: In function 'int main()':
mobile.cpp:83:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long double>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   83 |     for (int i = 0; i < bps.size(); i++)
      |                     ~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 360 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 860 KB Output is correct
3 Correct 1 ms 600 KB Output is correct
4 Correct 1 ms 772 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 600 KB Output is correct
2 Correct 3 ms 856 KB Output is correct
3 Correct 1 ms 856 KB Output is correct
4 Correct 2 ms 860 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 604 KB Output is correct
2 Correct 2 ms 860 KB Output is correct
3 Correct 1 ms 600 KB Output is correct
4 Correct 2 ms 988 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 860 KB Output is correct
2 Correct 2 ms 860 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 2 ms 860 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 7876 KB Output is correct
2 Correct 35 ms 6260 KB Output is correct
3 Correct 22 ms 5588 KB Output is correct
4 Correct 36 ms 8392 KB Output is correct
5 Correct 6 ms 1112 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 2136 KB Output is correct
2 Correct 27 ms 4820 KB Output is correct
3 Correct 36 ms 8144 KB Output is correct
4 Correct 38 ms 8728 KB Output is correct
5 Correct 41 ms 9172 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 14272 KB Output is correct
2 Correct 33 ms 6064 KB Output is correct
3 Correct 43 ms 12744 KB Output is correct
4 Correct 47 ms 10188 KB Output is correct
5 Correct 29 ms 3548 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 5720 KB Output is correct
2 Correct 44 ms 5836 KB Output is correct
3 Correct 32 ms 3672 KB Output is correct
4 Correct 45 ms 10384 KB Output is correct
5 Correct 45 ms 9156 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 43 ms 12612 KB Output is correct
2 Correct 41 ms 5692 KB Output is correct
3 Correct 33 ms 3928 KB Output is correct
4 Correct 45 ms 10356 KB Output is correct
5 Correct 44 ms 9156 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 241 ms 70380 KB Output is correct
2 Correct 151 ms 9040 KB Output is correct
3 Correct 151 ms 9012 KB Output is correct
4 Correct 267 ms 48060 KB Output is correct
5 Correct 256 ms 45348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 163 ms 9044 KB Output is correct
2 Correct 238 ms 49696 KB Output is correct
3 Correct 224 ms 27336 KB Output is correct
4 Correct 258 ms 58560 KB Output is correct
5 Correct 262 ms 52416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 303 ms 99300 KB Output is correct
2 Correct 172 ms 10324 KB Output is correct
3 Correct 192 ms 10396 KB Output is correct
4 Correct 320 ms 64824 KB Output is correct
5 Correct 292 ms 46924 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 178 ms 10324 KB Output is correct
2 Correct 322 ms 63476 KB Output is correct
3 Correct 247 ms 26836 KB Output is correct
4 Correct 333 ms 75832 KB Output is correct
5 Correct 306 ms 68084 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 339 ms 111536 KB Output is correct
2 Correct 204 ms 22612 KB Output is correct
3 Correct 203 ms 22100 KB Output is correct
4 Correct 390 ms 85136 KB Output is correct
5 Correct 336 ms 46276 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 203 ms 11776 KB Output is correct
2 Correct 349 ms 71100 KB Output is correct
3 Correct 322 ms 36500 KB Output is correct
4 Correct 400 ms 84884 KB Output is correct
5 Correct 374 ms 75712 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 403 ms 124072 KB Output is correct
2 Correct 221 ms 25940 KB Output is correct
3 Correct 213 ms 24924 KB Output is correct
4 Correct 432 ms 95240 KB Output is correct
5 Correct 390 ms 63684 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 220 ms 13392 KB Output is correct
2 Correct 385 ms 78728 KB Output is correct
3 Correct 358 ms 38568 KB Output is correct
4 Correct 419 ms 94908 KB Output is correct
5 Correct 415 ms 82880 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 428 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 246 ms 16468 KB Output is correct
2 Correct 536 ms 97704 KB Output is correct
3 Correct 482 ms 51532 KB Output is correct
4 Correct 549 ms 116476 KB Output is correct
5 Correct 515 ms 99772 KB Output is correct