Submission #995188

# Submission time Handle Problem Language Result Execution time Memory
995188 2024-06-08T15:19:03 Z VMaksimoski008 Mobile (BOI12_mobile) C++17
50 / 100
1000 ms 48444 KB
#include <bits/stdc++.h>

#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define int long long

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;

const int mod = 1e9 + 7;
const int LOG = 20;
const int maxn = 1e5 + 5;
const double eps = 1e-9;

int32_t main() {
    ios_base::sync_with_stdio(false);
    cout.tie(0); cin.tie(0);

    int n, L, mn=1e9;
    cin >> n >> L;

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

    double l=mn, r=5e9, ans=r;
    // double l = 5.545455, r=10, ans=r;
    for(int it=0; it<100; it++) {
        double mid = (l + r) / 2.0;
        vector<pdd> seg;
        //cout << mid << '\n';

        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) });
            //cout << seg.back().first << " " << seg.back().second << '\n';
        }

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

        sort(seg.begin(), seg.end());
        bool ok = 1;

        double lp=seg[0].first, rp=seg[0].second;
        if(lp > 0) ok = 0;

        for(int i=1; i<seg.size(); i++) {
            if(seg[i].first > rp) ok = 0;
            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:58: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]
   58 |         for(int i=1; i<seg.size(); 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 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 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 5 ms 604 KB Output is correct
2 Correct 7 ms 604 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 3 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 748 KB Output is correct
2 Correct 15 ms 748 KB Output is correct
3 Correct 19 ms 744 KB Output is correct
4 Correct 4 ms 748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 748 KB Output is correct
2 Correct 15 ms 756 KB Output is correct
3 Correct 18 ms 732 KB Output is correct
4 Correct 3 ms 748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 748 KB Output is correct
2 Correct 19 ms 748 KB Output is correct
3 Correct 29 ms 744 KB Output is correct
4 Correct 4 ms 732 KB Output is correct
5 Correct 5 ms 760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 133 ms 4924 KB Output is correct
2 Correct 447 ms 4968 KB Output is correct
3 Correct 270 ms 3172 KB Output is correct
4 Correct 52 ms 4896 KB Output is correct
5 Correct 53 ms 3072 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 82 ms 5036 KB Output is correct
2 Correct 67 ms 4792 KB Output is correct
3 Correct 68 ms 5080 KB Output is correct
4 Correct 59 ms 5032 KB Output is correct
5 Correct 50 ms 5212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 387 ms 5308 KB Output is correct
2 Correct 494 ms 5136 KB Output is correct
3 Correct 657 ms 5216 KB Output is correct
4 Correct 47 ms 5556 KB Output is correct
5 Correct 88 ms 5360 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 468 ms 5688 KB Output is correct
2 Correct 655 ms 5704 KB Output is correct
3 Correct 871 ms 5664 KB Output is correct
4 Correct 49 ms 5552 KB Output is correct
5 Correct 83 ms 5684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 178 ms 5656 KB Output is correct
2 Correct 625 ms 5696 KB Output is correct
3 Correct 864 ms 5660 KB Output is correct
4 Correct 51 ms 5660 KB Output is correct
5 Correct 82 ms 5672 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1062 ms 24328 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1056 ms 24532 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1072 ms 37612 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1026 ms 37668 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1018 ms 39340 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1026 ms 38944 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1057 ms 42136 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1031 ms 42804 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1061 ms 48444 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1051 ms 48316 KB Time limit exceeded
2 Halted 0 ms 0 KB -