답안 #995187

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
995187 2024-06-08T15:18:10 Z VMaksimoski008 Mobile (BOI12_mobile) C++17
50 / 100
1000 ms 48428 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=1e10, 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++) {
      |                      ~^~~~~~~~~~~
# 결과 실행 시간 메모리 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 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
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 600 KB Output is correct
2 Correct 6 ms 604 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 3 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 748 KB Output is correct
2 Correct 15 ms 760 KB Output is correct
3 Correct 19 ms 748 KB Output is correct
4 Correct 4 ms 744 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 748 KB Output is correct
2 Correct 17 ms 1100 KB Output is correct
3 Correct 24 ms 748 KB Output is correct
4 Correct 4 ms 748 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 748 KB Output is correct
2 Correct 15 ms 748 KB Output is correct
3 Correct 25 ms 744 KB Output is correct
4 Correct 4 ms 732 KB Output is correct
5 Correct 6 ms 736 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 135 ms 4900 KB Output is correct
2 Correct 439 ms 4964 KB Output is correct
3 Correct 267 ms 3172 KB Output is correct
4 Correct 56 ms 4892 KB Output is correct
5 Correct 57 ms 3096 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 106 ms 5000 KB Output is correct
2 Correct 71 ms 4756 KB Output is correct
3 Correct 71 ms 5064 KB Output is correct
4 Correct 61 ms 5008 KB Output is correct
5 Correct 54 ms 5912 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 394 ms 5324 KB Output is correct
2 Correct 487 ms 5152 KB Output is correct
3 Correct 651 ms 5224 KB Output is correct
4 Correct 47 ms 7580 KB Output is correct
5 Correct 90 ms 6240 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 468 ms 5712 KB Output is correct
2 Correct 627 ms 5800 KB Output is correct
3 Correct 865 ms 6948 KB Output is correct
4 Correct 48 ms 8040 KB Output is correct
5 Correct 88 ms 6956 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 188 ms 5604 KB Output is correct
2 Correct 638 ms 5696 KB Output is correct
3 Correct 859 ms 6728 KB Output is correct
4 Correct 52 ms 7556 KB Output is correct
5 Correct 87 ms 6956 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1103 ms 24408 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1016 ms 24312 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1030 ms 37440 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1087 ms 36132 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1049 ms 40456 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1060 ms 38832 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1039 ms 42252 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1050 ms 43548 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1048 ms 48428 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1054 ms 48280 KB Time limit exceeded
2 Halted 0 ms 0 KB -