Submission #842788

#TimeUsernameProblemLanguageResultExecution timeMemory
842788vjudge1Sure Bet (CEOI17_sure)C++17
100 / 100
72 ms4732 KiB
#include<bits/stdc++.h> #define int long long #define pb push_back #define x first #define y second #define getbit(u,i) ((u>>i)&1) #define all(x) x.begin(),x.end() #define N 200001 using namespace std; typedef pair<int,int> ii; typedef pair<double,double> dd; int n; double a[N],b[N],sa[N],sb[N],ans; double f(int na,int nb) { return min(sa[na]-nb,sb[nb]-na); } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n; for(int i=1;i<=n;i++) cin>>a[i]>>b[i]; sort(a+1,a+n+1,greater<double>()); sort(b+1,b+n+1,greater<double>()); for(int i=1;i<=n;i++) { sa[i]=sa[i-1]+a[i]-1; sb[i]=sb[i-1]+b[i]-1; } for(int i=1;i<=n;i++) { int lo=-1,hi=n; while(hi-lo>1) { int mid=(hi+lo)>>1; if(f(i,mid)>f(i,mid+1)) hi=mid; else lo=mid; } ans=max(ans,f(i,lo+1)); } cout<<setprecision(4)<<fixed<<ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...