Submission #928405

#TimeUsernameProblemLanguageResultExecution timeMemory
928405AiperiiiSure Bet (CEOI17_sure)C++14
100 / 100
123 ms5228 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; 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]; a[i]--;b[i]--; } sort(all(a));sort(all(b)); reverse(all(a));reverse(all(b)); long double p1=0,p2=0; long double sum1=0,sum2=0; long double ans=0; while(p1<n){ sum1+=a[p1]; p1++; while(min(sum1-p2,sum2-p1)<=min(sum1-p2-1,sum2+b[p2]-p1) && p2<n){ sum2+=b[p2]; p2++; } ans=max(ans,min(sum1-p2,sum2-p1)); } 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...