Submission #903996

# Submission time Handle Problem Language Result Execution time Memory
903996 2024-01-11T16:34:11 Z Dec0Dedd Sure Bet (CEOI17_sure) C++14
0 / 100
1 ms 2408 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";
    
    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();
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Incorrect 1 ms 2408 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Incorrect 1 ms 2408 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Incorrect 1 ms 2408 KB Output isn't correct
3 Halted 0 ms 0 KB -