Submission #903996

#TimeUsernameProblemLanguageResultExecution timeMemory
903996Dec0DeddSure Bet (CEOI17_sure)C++14
0 / 100
1 ms2408 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...