답안 #995199

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
995199 2024-06-08T15:38:32 Z VMaksimoski008 Mobile (BOI12_mobile) C++17
90 / 100
1000 ms 48740 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=1.5e9, ans=r;
    for(int it=0; it<45; 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;
      |                ^~
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 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 2 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 728 KB Output is correct
2 Correct 6 ms 732 KB Output is correct
3 Correct 4 ms 716 KB Output is correct
4 Correct 4 ms 728 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 780 KB Output is correct
2 Correct 6 ms 732 KB Output is correct
3 Correct 6 ms 728 KB Output is correct
4 Correct 6 ms 720 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 716 KB Output is correct
2 Correct 6 ms 716 KB Output is correct
3 Correct 5 ms 716 KB Output is correct
4 Correct 4 ms 716 KB Output is correct
5 Correct 4 ms 732 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 61 ms 4844 KB Output is correct
2 Correct 103 ms 5052 KB Output is correct
3 Correct 72 ms 3168 KB Output is correct
4 Correct 51 ms 4848 KB Output is correct
5 Correct 36 ms 3028 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 60 ms 4972 KB Output is correct
2 Correct 52 ms 4764 KB Output is correct
3 Correct 60 ms 5072 KB Output is correct
4 Correct 54 ms 5020 KB Output is correct
5 Correct 58 ms 5196 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 108 ms 5344 KB Output is correct
2 Correct 140 ms 5124 KB Output is correct
3 Correct 78 ms 5196 KB Output is correct
4 Correct 61 ms 5552 KB Output is correct
5 Correct 58 ms 5984 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 132 ms 5692 KB Output is correct
2 Correct 126 ms 5736 KB Output is correct
3 Correct 102 ms 5720 KB Output is correct
4 Correct 64 ms 5544 KB Output is correct
5 Correct 70 ms 5928 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 75 ms 5540 KB Output is correct
2 Correct 128 ms 5680 KB Output is correct
3 Correct 103 ms 5672 KB Output is correct
4 Correct 76 ms 5404 KB Output is correct
5 Correct 66 ms 5664 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 504 ms 24396 KB Output is correct
2 Correct 585 ms 24336 KB Output is correct
3 Correct 554 ms 24352 KB Output is correct
4 Correct 314 ms 24120 KB Output is correct
5 Correct 311 ms 24308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 615 ms 24328 KB Output is correct
2 Correct 402 ms 24320 KB Output is correct
3 Correct 454 ms 24308 KB Output is correct
4 Correct 300 ms 24440 KB Output is correct
5 Correct 313 ms 24300 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 637 ms 36320 KB Output is correct
2 Correct 709 ms 36688 KB Output is correct
3 Correct 696 ms 38756 KB Output is correct
4 Correct 374 ms 35784 KB Output is correct
5 Correct 387 ms 36412 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 714 ms 36700 KB Output is correct
2 Correct 485 ms 36936 KB Output is correct
3 Correct 500 ms 35684 KB Output is correct
4 Correct 354 ms 35944 KB Output is correct
5 Correct 390 ms 35916 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 746 ms 40760 KB Output is correct
2 Correct 830 ms 40908 KB Output is correct
3 Correct 842 ms 39056 KB Output is correct
4 Correct 431 ms 42224 KB Output is correct
5 Correct 458 ms 39604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 836 ms 39800 KB Output is correct
2 Correct 552 ms 40692 KB Output is correct
3 Correct 572 ms 39560 KB Output is correct
4 Correct 431 ms 39272 KB Output is correct
5 Correct 442 ms 39172 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 799 ms 42492 KB Output is correct
2 Correct 902 ms 42068 KB Output is correct
3 Correct 926 ms 42512 KB Output is correct
4 Correct 540 ms 42972 KB Output is correct
5 Correct 514 ms 42420 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 878 ms 45864 KB Output is correct
2 Correct 630 ms 42756 KB Output is correct
3 Correct 778 ms 42508 KB Output is correct
4 Correct 482 ms 42532 KB Output is correct
5 Correct 540 ms 43496 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 978 ms 48400 KB Output is correct
2 Execution timed out 1052 ms 48740 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1041 ms 48612 KB Time limit exceeded
2 Halted 0 ms 0 KB -