답안 #995196

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
995196 2024-06-08T15:35:11 Z VMaksimoski008 Mobile (BOI12_mobile) C++17
100 / 100
981 ms 68260 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;
    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<50; 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;
        }

        //sort(seg.begin(), seg.end());
        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:57: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]
   57 |         for(int i=1; i<seg.size(); i++) {
      |                      ~^~~~~~~~~~~
mobile.cpp:55:16: warning: unused variable 'lp' [-Wunused-variable]
   55 |         double lp=seg[0].first, rp=seg[0].second;
      |                ^~
# 결과 실행 시간 메모리 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 1 ms 348 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 604 KB Output is correct
2 Correct 2 ms 612 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 748 KB Output is correct
2 Correct 5 ms 748 KB Output is correct
3 Correct 4 ms 748 KB Output is correct
4 Correct 3 ms 748 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 732 KB Output is correct
2 Correct 5 ms 748 KB Output is correct
3 Correct 4 ms 748 KB Output is correct
4 Correct 3 ms 748 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 748 KB Output is correct
2 Correct 5 ms 748 KB Output is correct
3 Correct 4 ms 748 KB Output is correct
4 Correct 4 ms 732 KB Output is correct
5 Correct 3 ms 748 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 51 ms 4924 KB Output is correct
2 Correct 91 ms 5800 KB Output is correct
3 Correct 63 ms 3224 KB Output is correct
4 Correct 32 ms 4900 KB Output is correct
5 Correct 32 ms 3104 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 48 ms 5024 KB Output is correct
2 Correct 38 ms 4792 KB Output is correct
3 Correct 36 ms 5932 KB Output is correct
4 Correct 33 ms 5804 KB Output is correct
5 Correct 32 ms 5228 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 96 ms 5424 KB Output is correct
2 Correct 84 ms 5956 KB Output is correct
3 Correct 56 ms 5468 KB Output is correct
4 Correct 29 ms 5564 KB Output is correct
5 Correct 49 ms 5364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 113 ms 5808 KB Output is correct
2 Correct 106 ms 5732 KB Output is correct
3 Correct 93 ms 5724 KB Output is correct
4 Correct 31 ms 5560 KB Output is correct
5 Correct 59 ms 5692 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 50 ms 5660 KB Output is correct
2 Correct 109 ms 5752 KB Output is correct
3 Correct 100 ms 5732 KB Output is correct
4 Correct 30 ms 5560 KB Output is correct
5 Correct 49 ms 5684 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 443 ms 24604 KB Output is correct
2 Correct 486 ms 32168 KB Output is correct
3 Correct 447 ms 31580 KB Output is correct
4 Correct 144 ms 33724 KB Output is correct
5 Correct 180 ms 31548 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 489 ms 24676 KB Output is correct
2 Correct 308 ms 30964 KB Output is correct
3 Correct 397 ms 30236 KB Output is correct
4 Correct 147 ms 33592 KB Output is correct
5 Correct 181 ms 31664 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 610 ms 35932 KB Output is correct
2 Correct 640 ms 46504 KB Output is correct
3 Correct 666 ms 44964 KB Output is correct
4 Correct 176 ms 48480 KB Output is correct
5 Correct 284 ms 45448 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 678 ms 36516 KB Output is correct
2 Correct 394 ms 43680 KB Output is correct
3 Correct 398 ms 43652 KB Output is correct
4 Correct 172 ms 49320 KB Output is correct
5 Correct 247 ms 45320 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 716 ms 40412 KB Output is correct
2 Correct 679 ms 50064 KB Output is correct
3 Correct 710 ms 50268 KB Output is correct
4 Correct 211 ms 54084 KB Output is correct
5 Correct 294 ms 48112 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 713 ms 40280 KB Output is correct
2 Correct 470 ms 49584 KB Output is correct
3 Correct 479 ms 47928 KB Output is correct
4 Correct 215 ms 52400 KB Output is correct
5 Correct 275 ms 49344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 798 ms 43204 KB Output is correct
2 Correct 833 ms 54876 KB Output is correct
3 Correct 782 ms 53740 KB Output is correct
4 Correct 234 ms 58728 KB Output is correct
5 Correct 355 ms 54496 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 805 ms 41936 KB Output is correct
2 Correct 493 ms 53340 KB Output is correct
3 Correct 678 ms 52084 KB Output is correct
4 Correct 237 ms 57632 KB Output is correct
5 Correct 355 ms 54240 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 897 ms 48212 KB Output is correct
2 Correct 923 ms 63760 KB Output is correct
3 Correct 949 ms 62936 KB Output is correct
4 Correct 292 ms 68260 KB Output is correct
5 Correct 413 ms 62464 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 981 ms 48272 KB Output is correct
2 Correct 563 ms 62216 KB Output is correct
3 Correct 804 ms 60680 KB Output is correct
4 Correct 285 ms 67904 KB Output is correct
5 Correct 376 ms 62980 KB Output is correct