Submission #995198

# Submission time Handle Problem Language Result Execution time Memory
995198 2024-06-08T15:38:05 Z VMaksimoski008 Mobile (BOI12_mobile) C++17
0 / 100
1000 ms 48964 KB
#include <bits/stdc++.h>
#define int long long

using namespace std;
using ll = long long;
using pdd = pair<double, double>;

int32_t main() {
    int n, L;
    cin >> n >> L;

    vector<int> x(n), y(n);
    for(int i=0; i<n; i++) cin >> x[i] >> y[i];

    double l=1, r=2e9, ans=r;
    for(int it=0; it<40; it++) {
        double mid = (l + r) / 2.0;
        vector<pdd> seg;

        for(int i=0; i<n; i++) {
            if(abs(y[i]) >= mid) continue;
            double len = sqrt(mid * mid - y[i] * y[i]);
            double left = x[i] - len, right = x[i] + len;
            if( right >= 0 && left <= L ) seg.push_back({ max((double)0, x[i] - len), min((double)L, x[i] + len) });
        }

        if(seg.size() == 0) {
            l = mid;
            continue;
        }

        bool ok = 1;
        double mn = 1e9;
        for(auto &s : seg) mn = min(mn, s.first);
        if(mn > 0) ok = 0;

        double lp=seg[0].first, rp=seg[0].second;

        for(int i=1; i<seg.size(); i++) {
            if(seg[i].first <= rp) rp = max(rp, seg[i].second);
        }

        if(ok && rp >= L) ans = min(ans, mid), r = mid;
        else l = mid;
    }

    cout << setprecision(8) << fixed << ans << '\n';
    return 0;
}

Compilation message

mobile.cpp: In function 'int32_t main()':
mobile.cpp:39:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<double, double> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |         for(int i=1; i<seg.size(); i++) {
      |                      ~^~~~~~~~~~~
mobile.cpp:37:16: warning: unused variable 'lp' [-Wunused-variable]
   37 |         double lp=seg[0].first, rp=seg[0].second;
      |                ^~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 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 Incorrect 1 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 732 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 728 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 716 KB Output is correct
2 Correct 6 ms 716 KB Output is correct
3 Correct 4 ms 732 KB Output is correct
4 Incorrect 4 ms 732 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 61 ms 4872 KB Output is correct
2 Incorrect 97 ms 4996 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 80 ms 4988 KB Output is correct
2 Correct 51 ms 4784 KB Output is correct
3 Incorrect 58 ms 5068 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 96 ms 5328 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 147 ms 5712 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 75 ms 5540 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 515 ms 24336 KB Output is correct
2 Correct 550 ms 24316 KB Output is correct
3 Correct 567 ms 24320 KB Output is correct
4 Correct 325 ms 24376 KB Output is correct
5 Incorrect 329 ms 24340 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 543 ms 24512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 625 ms 36996 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 700 ms 36892 KB Output is correct
2 Incorrect 513 ms 36692 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 720 ms 39236 KB Output is correct
2 Incorrect 797 ms 40632 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 795 ms 40732 KB Output is correct
2 Incorrect 518 ms 38980 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 744 ms 42040 KB Output is correct
2 Correct 883 ms 42360 KB Output is correct
3 Correct 874 ms 42188 KB Output is correct
4 Incorrect 497 ms 42992 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 892 ms 42924 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 936 ms 48188 KB Output is correct
2 Execution timed out 1002 ms 48964 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1026 ms 48252 KB Time limit exceeded
2 Halted 0 ms 0 KB -