답안 #903997

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
903997 2024-01-11T16:36:09 Z Dec0Dedd Sure Bet (CEOI17_sure) C++14
0 / 100
1 ms 2404 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;

const int N = 1e5+10;
const int K = 1e4;

ll a[N], b[N], p[N], n;

ll genx() {
    ll x=0, sm=0;
    for (ll i=1; i<=n; ++i) {
        sm+=a[i];

        ll lf=0, rf=n, res=0;
        while (lf <= rf) {
            ll m=(lf+rf)/2;
            if (sm-m*K >= p[m]-i*K) lf=m+1, res=m;
            else rf=m-1; 
        }

        ll val=max(min(sm-res*K, p[res]-i*K), min(sm-(res+1)*K, p[res+1]-i*K));
        x=max(x, val);
    } return x;
}

void solve() {
    cin>>n;
    for (int i=1; i<=n; ++i) {
        ld x; cin>>x;
        a[i]=K*x;
        cin>>x;
        b[i]=K*x, a[i]-=K, b[i]-=K;
    } sort(a+1, a+n+1, greater<ll>()), sort(b+1, b+n+1, greater<ll>());

    for (int i=1; i<=n+1; ++i) p[i]=p[i-1]+b[i];

    ll ans=genx();
    swap(a, b);

    p[0]=0;
    for (int i=1; i<=n+1; ++i) p[i]=p[i-1]+b[i];
    ans=max(ans, genx());

    //cout<<ans<<"\n";

    printf("%.4lf", (double)((ans*1.0)/(K*1.0)));

    /*
    cout<<setprecision(4)<<fixed;
    cout<<1.0*((ans*1.0)/(K*1.0))<<"\n";
    */
    
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int t=1;
    while (t--) solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2404 KB Output is correct
2 Incorrect 1 ms 2400 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2404 KB Output is correct
2 Incorrect 1 ms 2400 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2404 KB Output is correct
2 Incorrect 1 ms 2400 KB Output isn't correct
3 Halted 0 ms 0 KB -