Submission #1093462

# Submission time Handle Problem Language Result Execution time Memory
1093462 2024-09-26T21:14:23 Z selmahbn Mobile (BOI12_mobile) C++17
100 / 100
699 ms 50924 KB
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define pdl pair<double, ll>

double sp(double x1, double y1, double x2, double y2) {
    double top = x2*x2 - x1*x1 + y2*y2 - y1*y1;
    double bottom = 2*x2 - 2*x1;
    return top/bottom;
}

int main()
{
    ll n; double l;
    cin >> n >> l;
    vector<pdl> p(n);
    ll li = -1;
    vector<double> x(n);
    vector<double> y(n);
    for (ll i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
        double last;
        bool gleich = false;
        while (li >= 0) {
            double lsp, i2;
            tie(lsp, i2) = p[li];
            if (x[i] == x[i2]) {
                if (abs(y[i]) < abs(y[i2])) {
                    li--;
                    continue;
                } else {
                    gleich = true;
                    break;
                }
            }
            double csp = sp(x[i], y[i], x[i2], y[i2]);
            if (csp <= lsp) {
                li--;
            } else {
                last = csp;
                break;
            }
        }
        if (gleich) continue;
        if (li == -1) p[0] = make_pair(0, i);
        else p[li+1] = make_pair(last, i);
        li++;
    }
    double maxi = 0;
    ll last = p[0].second;
    for (ll i = 0; i <= li; i++) {
        double csp, ci;
        tie(csp, ci) = p[i];
        if (csp > l || i == li) {
            if (i == li && csp <= l) last = ci;
            double dist = sqrt((x[last]-l)*(x[last]-l)+y[last]*y[last]);
            maxi = max(maxi, dist);
            if (csp > l) break;
        }
        double dist = sqrt((x[ci]-csp)*(x[ci]-csp)+y[ci]*y[ci]);
        maxi = max(maxi, dist);
        last = ci;
    }
    cout.precision(4);
    cout << fixed << maxi;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 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 0 ms 348 KB Output is correct
3 Correct 1 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 1 ms 444 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 604 KB Output is correct
2 Correct 3 ms 604 KB Output is correct
3 Correct 2 ms 632 KB Output is correct
4 Correct 3 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 604 KB Output is correct
2 Correct 4 ms 652 KB Output is correct
3 Correct 3 ms 604 KB Output is correct
4 Correct 3 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 604 KB Output is correct
2 Correct 3 ms 660 KB Output is correct
3 Correct 4 ms 604 KB Output is correct
4 Correct 3 ms 600 KB Output is correct
5 Correct 2 ms 408 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 36 ms 3320 KB Output is correct
2 Correct 41 ms 3844 KB Output is correct
3 Correct 26 ms 2652 KB Output is correct
4 Correct 47 ms 3936 KB Output is correct
5 Correct 20 ms 2392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 35 ms 3420 KB Output is correct
2 Correct 35 ms 3416 KB Output is correct
3 Correct 43 ms 3932 KB Output is correct
4 Correct 46 ms 3920 KB Output is correct
5 Correct 55 ms 4616 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 34 ms 3684 KB Output is correct
2 Correct 44 ms 3924 KB Output is correct
3 Correct 41 ms 3920 KB Output is correct
4 Correct 72 ms 5324 KB Output is correct
5 Correct 43 ms 3924 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 63 ms 4944 KB Output is correct
2 Correct 55 ms 4944 KB Output is correct
3 Correct 49 ms 4692 KB Output is correct
4 Correct 70 ms 5456 KB Output is correct
5 Correct 52 ms 4704 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 57 ms 4944 KB Output is correct
2 Correct 53 ms 4956 KB Output is correct
3 Correct 45 ms 4436 KB Output is correct
4 Correct 68 ms 5456 KB Output is correct
5 Correct 54 ms 4688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 200 ms 20300 KB Output is correct
2 Correct 293 ms 23740 KB Output is correct
3 Correct 265 ms 23120 KB Output is correct
4 Correct 379 ms 25412 KB Output is correct
5 Correct 274 ms 22868 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 291 ms 24132 KB Output is correct
2 Correct 270 ms 22592 KB Output is correct
3 Correct 264 ms 21588 KB Output is correct
4 Correct 347 ms 25412 KB Output is correct
5 Correct 291 ms 23376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 271 ms 24180 KB Output is correct
2 Correct 350 ms 28280 KB Output is correct
3 Correct 331 ms 27732 KB Output is correct
4 Correct 410 ms 30856 KB Output is correct
5 Correct 352 ms 26964 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 371 ms 28944 KB Output is correct
2 Correct 337 ms 26960 KB Output is correct
3 Correct 278 ms 26000 KB Output is correct
4 Correct 423 ms 30800 KB Output is correct
5 Correct 333 ms 27728 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 282 ms 28240 KB Output is correct
2 Correct 416 ms 32968 KB Output is correct
3 Correct 389 ms 32336 KB Output is correct
4 Correct 498 ms 35724 KB Output is correct
5 Correct 415 ms 31288 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 419 ms 33872 KB Output is correct
2 Correct 372 ms 31556 KB Output is correct
3 Correct 333 ms 30652 KB Output is correct
4 Correct 474 ms 35668 KB Output is correct
5 Correct 398 ms 32332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 334 ms 32372 KB Output is correct
2 Correct 510 ms 37616 KB Output is correct
3 Correct 439 ms 36944 KB Output is correct
4 Correct 547 ms 41044 KB Output is correct
5 Correct 438 ms 36596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 524 ms 38520 KB Output is correct
2 Correct 428 ms 35920 KB Output is correct
3 Correct 388 ms 34900 KB Output is correct
4 Correct 555 ms 40836 KB Output is correct
5 Correct 487 ms 36944 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 403 ms 40276 KB Output is correct
2 Correct 568 ms 47232 KB Output is correct
3 Correct 559 ms 46160 KB Output is correct
4 Correct 699 ms 50892 KB Output is correct
5 Correct 542 ms 45396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 628 ms 48208 KB Output is correct
2 Correct 525 ms 44776 KB Output is correct
3 Correct 493 ms 43900 KB Output is correct
4 Correct 694 ms 50924 KB Output is correct
5 Correct 582 ms 46416 KB Output is correct