// Bolatulu
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
#define int long long
#define kanagattandirilmagandiktarinizdan ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define F first
#define S second
#define md (tl+tr)/2
#define TL v+v,tl,mid
#define TR v+v+1,mid+1,tr
#pragma GCC target( "sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast,unroll-loops,fast-math,O3")
using namespace std;
int binpow(int a,int n,int M) {
if (n==0)
return 1;
if (n%2!=0)
return (a * binpow(a,n-1,M))%M;
int z=binpow(a,n/2,M);
return (z*z)%M;
}
const ll INF = 1e18;
const int N = 1e6+7;
const int M = 1e9+7;
const ll HZ = 1e5;
const int MAX = INT_MAX;
const int MIN = INT_MIN;
const db pi = 3.141592653;
const int P=31;
int n;
db a[N],b[N],ans;
void rec(int pos,db sum1,db sum2,db cnt) {
if (pos>n) {
ans = max(ans, min(sum1, sum2) - cnt);
return;
}
rec(pos+1,sum1+a[pos],sum2,cnt+1), rec(pos+1,sum1, sum2+b[pos],cnt+1), rec(pos+1,sum1+a[pos],sum2+b[pos],cnt+2), rec(pos+1,sum1,sum2,cnt);
}
void solve() {
cin >> n;
for (int i=1;i<=n;i++)
cin >> a[i] >> b[i];
rec(1,0,0,0);
printf("%.4lf",(double)ans);
}
signed main() {
// freopen("lca.in", "r", stdin);
// freopen("lca.out", "w", stdout);
kanagattandirilmagandiktarinizdan
int test = 1, count = 1;
// cin >> test;
while (test--) {
// cout << "Case " << count << ":\n";
solve();
if (test)
// cout << '\n';
count++;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
10 ms |
2396 KB |
Output is correct |
4 |
Correct |
10 ms |
2512 KB |
Output is correct |
5 |
Correct |
9 ms |
2396 KB |
Output is correct |
6 |
Correct |
10 ms |
2396 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
10 ms |
2396 KB |
Output is correct |
4 |
Correct |
10 ms |
2512 KB |
Output is correct |
5 |
Correct |
9 ms |
2396 KB |
Output is correct |
6 |
Correct |
10 ms |
2396 KB |
Output is correct |
7 |
Execution timed out |
2044 ms |
2396 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
10 ms |
2396 KB |
Output is correct |
4 |
Correct |
10 ms |
2512 KB |
Output is correct |
5 |
Correct |
9 ms |
2396 KB |
Output is correct |
6 |
Correct |
10 ms |
2396 KB |
Output is correct |
7 |
Execution timed out |
2044 ms |
2396 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |