Submission #1095259

# Submission time Handle Problem Language Result Execution time Memory
1095259 2024-10-01T16:49:11 Z buzdi Mobile (BOI12_mobile) C++17
100 / 100
332 ms 63056 KB
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <vector>
#include <queue>
#include <map>
#include <set>
#define ll long long

using namespace std;

const int NMAX = 1e6;
const long double EPS = 1e-3;

struct Point {
    long double x, y;
    void read() {
        cin >> x >> y;
    }
}points[NMAX + 1];

int n, l, ind_st, i;
long double answer;
pair<int, long double> st[NMAX + 1];

long double Square(long double x) {
    return x * x;
}

long double Distance(Point p1, Point p2) {
    return sqrt(Square(p1.x - p2.x) + Square(p1.y - p2.y));
}

long double WhereBetter(Point p1, Point p2) {
    return (long double)(Square(p2.x) + Square(p2.y) - Square(p1.x) - Square(p1.y)) / (long double)(2 * (p2.x - p1.x));
}

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

    cin >> n >> l;
    for (int i = 1; i <= n; i++) {
        points[i].read();
    }

    i = 1;
    while (i <= n) {
        Point best_point = points[i];
        int pos_best_point = i;
        i++;
        while (i <= n && points[i].x == points[i - 1].x) {
            if (abs(points[i].y) < abs(best_point.y)) {
                best_point = points[i];
                pos_best_point = i;
            }
            i++;
        }

        if (ind_st >= 1 && WhereBetter(best_point, points[st[ind_st].first]) > l) {
            continue;
        }

        while (ind_st >= 1 && WhereBetter(best_point, points[st[ind_st].first]) < st[ind_st].second) {
            ind_st--;
        }

        if (ind_st == 0) {
            st[++ind_st] = { pos_best_point, 0 };
        }
        else {
            long double x = WhereBetter(best_point, points[st[ind_st].first]);
            st[++ind_st] = { pos_best_point, x };
        }
    }
    //for (int i = 1; i <= n; i++) {
    //    if (ind_st >= 1 && points[i].x == points[st[ind_st].first].x) {
    //        continue;
    //    }

    //    if (ind_st >= 1 && WhereBetter(points[i], points[st[ind_st].first]) > l) {
    //        continue;
    //    }

    //    while (ind_st >= 1 && WhereBetter(points[i], points[st[ind_st].first]) < st[ind_st].second) {
    //        ind_st--;
    //    }

    //    if (ind_st == 0) {
    //        st[++ind_st] = { i, 1 };
    //    }
    //    else {
    //        long double x = WhereBetter(points[i], points[st[ind_st].first]);
    //        st[++ind_st] = { i, x };
    //    }
    //}

    for (int i = 1; i <= ind_st; i++) {
        answer = max(answer, max(Distance(points[st[i].first], { st[i].second, 0 }), Distance(points[st[i].first], { (i == ind_st ? l : st[i + 1].second - EPS), 0 })));
    }
    cout << fixed << setprecision(6) << answer << '\n';

    return 0;
}
# 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 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 604 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 600 KB Output is correct
2 Correct 2 ms 600 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 2 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 604 KB Output is correct
2 Correct 2 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 2 ms 476 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 600 KB Output is correct
2 Correct 2 ms 604 KB Output is correct
3 Correct 2 ms 604 KB Output is correct
4 Correct 3 ms 604 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 2864 KB Output is correct
2 Correct 21 ms 2652 KB Output is correct
3 Correct 14 ms 2648 KB Output is correct
4 Correct 23 ms 3924 KB Output is correct
5 Correct 12 ms 2392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 36 ms 2852 KB Output is correct
2 Correct 19 ms 2652 KB Output is correct
3 Correct 29 ms 2980 KB Output is correct
4 Correct 24 ms 2908 KB Output is correct
5 Correct 38 ms 3176 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 5716 KB Output is correct
2 Correct 22 ms 2904 KB Output is correct
3 Correct 23 ms 5032 KB Output is correct
4 Correct 33 ms 5376 KB Output is correct
5 Correct 23 ms 4188 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 27 ms 3412 KB Output is correct
2 Correct 33 ms 5248 KB Output is correct
3 Correct 25 ms 4852 KB Output is correct
4 Correct 34 ms 5460 KB Output is correct
5 Correct 28 ms 4700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 33 ms 4180 KB Output is correct
2 Correct 28 ms 3416 KB Output is correct
3 Correct 24 ms 4700 KB Output is correct
4 Correct 42 ms 5672 KB Output is correct
5 Correct 33 ms 4688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 131 ms 31572 KB Output is correct
2 Correct 135 ms 15912 KB Output is correct
3 Correct 142 ms 23120 KB Output is correct
4 Correct 168 ms 25680 KB Output is correct
5 Correct 145 ms 22868 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 139 ms 15956 KB Output is correct
2 Correct 140 ms 23256 KB Output is correct
3 Correct 129 ms 23120 KB Output is correct
4 Correct 162 ms 25296 KB Output is correct
5 Correct 159 ms 23292 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 165 ms 37976 KB Output is correct
2 Correct 167 ms 19028 KB Output is correct
3 Correct 163 ms 27732 KB Output is correct
4 Correct 219 ms 31052 KB Output is correct
5 Correct 170 ms 27036 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 185 ms 19240 KB Output is correct
2 Correct 168 ms 27668 KB Output is correct
3 Correct 155 ms 27036 KB Output is correct
4 Correct 192 ms 30800 KB Output is correct
5 Correct 211 ms 27732 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 193 ms 44212 KB Output is correct
2 Correct 187 ms 22324 KB Output is correct
3 Correct 197 ms 32488 KB Output is correct
4 Correct 244 ms 35668 KB Output is correct
5 Correct 205 ms 31320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 204 ms 22348 KB Output is correct
2 Correct 215 ms 32240 KB Output is correct
3 Correct 177 ms 32560 KB Output is correct
4 Correct 229 ms 35664 KB Output is correct
5 Correct 208 ms 32364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 226 ms 50452 KB Output is correct
2 Correct 222 ms 25428 KB Output is correct
3 Correct 213 ms 36944 KB Output is correct
4 Correct 281 ms 41052 KB Output is correct
5 Correct 262 ms 36480 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 240 ms 25428 KB Output is correct
2 Correct 236 ms 36820 KB Output is correct
3 Correct 212 ms 36692 KB Output is correct
4 Correct 289 ms 40788 KB Output is correct
5 Correct 241 ms 36948 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 263 ms 63056 KB Output is correct
2 Correct 272 ms 31568 KB Output is correct
3 Correct 268 ms 46160 KB Output is correct
4 Correct 332 ms 50768 KB Output is correct
5 Correct 289 ms 45140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 278 ms 31616 KB Output is correct
2 Correct 278 ms 45700 KB Output is correct
3 Correct 262 ms 46416 KB Output is correct
4 Correct 329 ms 51024 KB Output is correct
5 Correct 297 ms 46300 KB Output is correct