Submission #938331

#TimeUsernameProblemLanguageResultExecution timeMemory
938331vjudge1Sure Bet (CEOI17_sure)C++17
100 / 100
105 ms2136 KiB
#include <bits/stdc++.h> #define int long long #define ff first #define ss second #define pb push_back #define all(x) x.begin(),x.end() using namespace std; signed main(){ ios_base::sync_with_stdio(); cin.tie(0);cout.tie(0); int n; cin>>n; vector <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)); double ans=0; double sum1=0,sum2=0; int cnt=0; for(int i=0;i<n;i++){ sum1+=a[i]; while(cnt<n && min(sum1-cnt,sum2-i-1)<=min(sum1-cnt-1,sum2+b[cnt]-i-1)){ sum2+=b[cnt]; cnt++; } ans=max(ans,min(sum1-cnt,sum2-i-1)); } 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...