답안 #995186

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
995186 2024-06-08T15:17:38 Z VMaksimoski008 Mobile (BOI12_mobile) C++17
35 / 100
1000 ms 48468 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<200; 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 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 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 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 604 KB Output is correct
2 Correct 12 ms 604 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 5 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 744 KB Output is correct
2 Correct 29 ms 756 KB Output is correct
3 Correct 31 ms 748 KB Output is correct
4 Correct 5 ms 748 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 748 KB Output is correct
2 Correct 31 ms 760 KB Output is correct
3 Correct 30 ms 808 KB Output is correct
4 Correct 5 ms 744 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 748 KB Output is correct
2 Correct 29 ms 756 KB Output is correct
3 Correct 57 ms 756 KB Output is correct
4 Correct 5 ms 728 KB Output is correct
5 Correct 6 ms 740 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 229 ms 4904 KB Output is correct
2 Correct 910 ms 5152 KB Output is correct
3 Correct 549 ms 3792 KB Output is correct
4 Correct 68 ms 6104 KB Output is correct
5 Correct 63 ms 3488 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 96 ms 5008 KB Output is correct
2 Correct 79 ms 5656 KB Output is correct
3 Correct 88 ms 5104 KB Output is correct
4 Correct 79 ms 5008 KB Output is correct
5 Correct 69 ms 5212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 830 ms 5316 KB Output is correct
2 Correct 958 ms 5840 KB Output is correct
3 Execution timed out 1031 ms 6152 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 875 ms 6224 KB Output is correct
2 Execution timed out 1072 ms 5756 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 283 ms 5660 KB Output is correct
2 Execution timed out 1070 ms 5700 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1067 ms 24348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1028 ms 24332 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1030 ms 36956 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1064 ms 36688 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1042 ms 40600 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1020 ms 40820 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1066 ms 44172 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1087 ms 42384 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1058 ms 48468 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1061 ms 48316 KB Time limit exceeded
2 Halted 0 ms 0 KB -