답안 #995197

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
995197 2024-06-08T15:37:10 Z VMaksimoski008 Mobile (BOI12_mobile) C++17
90 / 100
1000 ms 56860 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<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 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 2 ms 344 KB Output is correct
2 Correct 2 ms 600 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 2 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 776 KB Output is correct
2 Correct 6 ms 780 KB Output is correct
3 Correct 4 ms 760 KB Output is correct
4 Correct 4 ms 792 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 776 KB Output is correct
2 Correct 8 ms 956 KB Output is correct
3 Correct 5 ms 764 KB Output is correct
4 Correct 4 ms 796 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 776 KB Output is correct
2 Correct 6 ms 792 KB Output is correct
3 Correct 5 ms 764 KB Output is correct
4 Correct 4 ms 812 KB Output is correct
5 Correct 4 ms 764 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 62 ms 5636 KB Output is correct
2 Correct 110 ms 5804 KB Output is correct
3 Correct 54 ms 3676 KB Output is correct
4 Correct 51 ms 6504 KB Output is correct
5 Correct 39 ms 3460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 58 ms 5532 KB Output is correct
2 Correct 54 ms 5544 KB Output is correct
3 Correct 59 ms 5864 KB Output is correct
4 Correct 55 ms 5728 KB Output is correct
5 Correct 58 ms 6200 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 105 ms 5868 KB Output is correct
2 Correct 108 ms 5944 KB Output is correct
3 Correct 75 ms 5972 KB Output is correct
4 Correct 62 ms 6828 KB Output is correct
5 Correct 63 ms 6060 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 135 ms 6772 KB Output is correct
2 Correct 122 ms 6792 KB Output is correct
3 Correct 107 ms 6444 KB Output is correct
4 Correct 64 ms 6820 KB Output is correct
5 Correct 68 ms 6444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 79 ms 6596 KB Output is correct
2 Correct 123 ms 6772 KB Output is correct
3 Correct 96 ms 6888 KB Output is correct
4 Correct 64 ms 6824 KB Output is correct
5 Correct 69 ms 6412 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 430 ms 27016 KB Output is correct
2 Correct 516 ms 28828 KB Output is correct
3 Correct 553 ms 28244 KB Output is correct
4 Correct 305 ms 29236 KB Output is correct
5 Correct 326 ms 27896 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 570 ms 28704 KB Output is correct
2 Correct 421 ms 28052 KB Output is correct
3 Correct 496 ms 27380 KB Output is correct
4 Correct 307 ms 29232 KB Output is correct
5 Correct 311 ms 28180 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 638 ms 39916 KB Output is correct
2 Correct 745 ms 42428 KB Output is correct
3 Correct 738 ms 40936 KB Output is correct
4 Correct 366 ms 42420 KB Output is correct
5 Correct 393 ms 40576 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 760 ms 41444 KB Output is correct
2 Correct 492 ms 41440 KB Output is correct
3 Correct 495 ms 39920 KB Output is correct
4 Correct 371 ms 42932 KB Output is correct
5 Correct 387 ms 42160 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 726 ms 43320 KB Output is correct
2 Correct 744 ms 47856 KB Output is correct
3 Correct 803 ms 44956 KB Output is correct
4 Correct 423 ms 46336 KB Output is correct
5 Correct 458 ms 45512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 853 ms 45932 KB Output is correct
2 Correct 552 ms 44796 KB Output is correct
3 Correct 576 ms 44840 KB Output is correct
4 Correct 415 ms 46528 KB Output is correct
5 Correct 432 ms 45248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 786 ms 46464 KB Output is correct
2 Correct 898 ms 49512 KB Output is correct
3 Correct 888 ms 48236 KB Output is correct
4 Correct 496 ms 51796 KB Output is correct
5 Correct 518 ms 49016 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 948 ms 50312 KB Output is correct
2 Correct 614 ms 49104 KB Output is correct
3 Correct 771 ms 47204 KB Output is correct
4 Correct 481 ms 50564 KB Output is correct
5 Correct 483 ms 48552 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 961 ms 52776 KB Output is correct
2 Execution timed out 1055 ms 56532 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1031 ms 56860 KB Time limit exceeded
2 Halted 0 ms 0 KB -