#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);
}
}
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
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
43 ms |
348 KB |
Output is correct |
4 |
Correct |
43 ms |
348 KB |
Output is correct |
5 |
Correct |
43 ms |
348 KB |
Output is correct |
6 |
Correct |
43 ms |
600 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
43 ms |
348 KB |
Output is correct |
4 |
Correct |
43 ms |
348 KB |
Output is correct |
5 |
Correct |
43 ms |
348 KB |
Output is correct |
6 |
Correct |
43 ms |
600 KB |
Output is correct |
7 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
43 ms |
348 KB |
Output is correct |
4 |
Correct |
43 ms |
348 KB |
Output is correct |
5 |
Correct |
43 ms |
348 KB |
Output is correct |
6 |
Correct |
43 ms |
600 KB |
Output is correct |
7 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |