답안 #938320

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
938320 2024-03-05T04:37:11 Z vjudge1 Sure Bet (CEOI17_sure) C++17
0 / 100
0 ms 348 KB
#include <bits/stdc++.h>

using namespace std;

#define all(x) x.begin(), x.end()
#define ar array
#define pb push_back
#define ln '\n'
#define int long long

using i64 = long long;

template <class F, class _S>
bool chmin(F &u, const _S &v){
    bool flag = false;
    if ( u > v ){
        u = v; flag |= true;
    }
    return flag;
}

template <class F, class _S>
bool chmax(F &u, const _S &v){
    bool flag = false;
    if ( u < v ){
        u = v; flag |= true;
    }
    return flag;
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int n; cin >> n;
    using ld = long double;
    vector <ld> a, b;
    for ( int i = 0; i < n; i++ ){
        ld x, y; cin >> x >> y;
        if ( x > 1 ) a.pb(x);
        if ( y > 1 ) b.pb(y);
    }
    sort(all(a), greater <ld> ());
    sort(all(b), greater <ld> ());
    n = a.size();
    int m = b.size();
    vector <ld> pf(m + 1), mx(m + 1);
    for ( int i = 0; i < m; i++ ){
        pf[i + 1] = pf[i] + b[i];
        mx[i + 1] = max(mx[i], b[i] - (i + 1));
    }
    auto ok = [&](ld x){
        ld s = 0;
        for ( int i = 0; i <= n; i++ ){
            int j = max(0LL, (int)floor(s - x - i));
            chmin(j, m);
            if ( s - i >= x && mx[j] - i >= x ){
                return true;
            }
            if ( i < n ){
                s += a[i];
            }
        } return false;
    };
    ld l = 0, r = 1e12;
    for ( int _ = 0; _ <= 100; _++ ){
        ld md = (l + r) / 2;
        if ( ok(md) ) l = md;
        else r = md;
    }
    cout << fixed << setprecision(4) << l;

    cout << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -