This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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];
}
long double ans=-1e9;
for(int mask1=0;mask1<(1<<n);mask1++){
long double sum1=0,cnt1=0;
for(int i=0;i<n;i++){
if((mask1 & (1<<i))!=0){
cnt1++;
sum1+=a[i];
}
}
//cout<<sum1<<" "<<cnt1<<"\n";
for(int mask2=0;mask2<(1<<n);mask2++){
long double sum2=0,cnt2=0;
for(int i=0;i<n;i++){
if((mask2 & (1<<i))!=0){
cnt2++;
sum2+=b[i];
}
}
long double x=min(sum1-cnt1-cnt2,sum2-cnt1-cnt2);
ans=max(ans,x);
}
}
cout<<fixed<<setprecision(4)<<ans<<"\n";
}
/*
4
1.4 3.7
1.2 2
1.6 1.4
1.9 1.5
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |