#include <bits/stdc++.h>
#define int long long
//#define double long double
#define Nanase_Kurumi_aka_menhera_chan_is_mine ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define pi pair<double,int>
#define ALL(i) i.begin(),i.end()
#define gcd(i,j) __gcd(i,j)
#define fi first
#define se second
#define eps 0.00000001
#define ist insert
#define DNE nullptr
//#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
//#pragma GCC optimize("O2")
int max(int x,int y){return x>=y?x:y;}
int min(int x,int y){return x>=y?y:x;}
using namespace std;
typedef int ll;
const int N=100005;
const int M=1000005;
const int MOD=1000000007;//998244353;
const int INF=1000000000000000000;//2147483647;
double a[N],b[N];
double dp[N][4][3]; // 1 a 2 b 3 ab
pi c[2*N];
int n;
double ans=0;
vector<int> vc;
void check(){
double cnt=0,c[2]={0};
for (int i=0;i<n;i++){
if (vc[i]==1){
cnt++;
c[0]+=a[i];
}
if (vc[i]==2){
cnt++;
c[1]+=b[i];
}
if (vc[i]==3){
cnt+=2;
c[0]+=a[i];
c[1]+=b[i];
}
}
ans=max(ans,min(c[1],c[0])-cnt);
}
void dfs(int i){
if (i==n){
check();
return;
}
vc.pb(0);dfs(i+1);vc.pop_back();
vc.pb(1);dfs(i+1);vc.pop_back();
vc.pb(2);dfs(i+1);vc.pop_back();
vc.pb(3);dfs(i+1);vc.pop_back();
}
inline void sol(){
cin >>n;
for (int i=0;i<n;i++){
cin >>a[i]>>b[i];
}
dfs(0);
cout <<fixed<<setprecision(4)<<ans<<'\n';
}
/*
4
1.4 3.7
1.2 2
1.6 1.4
1.9 1.5
*/
signed main(){
Nanase_Kurumi_aka_menhera_chan_is_mine
int _=1;
//cin >>_;
while (_--) sol();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
3 |
Correct |
47 ms |
204 KB |
Output is correct |
4 |
Correct |
48 ms |
204 KB |
Output is correct |
5 |
Correct |
47 ms |
304 KB |
Output is correct |
6 |
Correct |
45 ms |
308 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
3 |
Correct |
47 ms |
204 KB |
Output is correct |
4 |
Correct |
48 ms |
204 KB |
Output is correct |
5 |
Correct |
47 ms |
304 KB |
Output is correct |
6 |
Correct |
45 ms |
308 KB |
Output is correct |
7 |
Execution timed out |
2073 ms |
316 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
3 |
Correct |
47 ms |
204 KB |
Output is correct |
4 |
Correct |
48 ms |
204 KB |
Output is correct |
5 |
Correct |
47 ms |
304 KB |
Output is correct |
6 |
Correct |
45 ms |
308 KB |
Output is correct |
7 |
Execution timed out |
2073 ms |
316 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |