Submission #928373

#TimeUsernameProblemLanguageResultExecution timeMemory
928373AiperiiiSure Bet (CEOI17_sure)C++14
60 / 100
2067 ms6976 KiB
#include <bits/stdc++.h> #define int long long #define ff first #define ss second #define all(x) x.begin(),x.end() #define pb push_back using namespace std; const int N=1e5+5; signed main(){ int n; cin>>n; vector <long double> a(n),b(n); for(int i=0;i<n;i++){ cin>>a[i]>>b[i]; } sort(all(a));sort(all(b)); for(int i=n-2;i>=0;i--){ a[i]+=a[i+1]; b[i]+=b[i+1]; } a.pb(0); b.pb(0); long double ans=-1e9; for(int i=n;i>=0;i--){ for(int j=n;j>=0;j--){ long double sum1=a[i],sum2=b[j]; long double cnt1=n-i,cnt2=n-j; long double x=min(sum1-cnt1-cnt2,sum2-cnt1-cnt2); ans=max(ans,x); } } if(ans<0)ans=0; cout<<fixed<<setprecision(4)<<ans<<"\n"; } /* 4 1.4 3.7 1.2 2 1.6 1.4 1.9 1.5 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...