#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define int long long
using namespace std;
//int pow(int a,int b,int m){int ans=1;while(b){if(b&1){ans=(ans*a)%m;}b>>=1;a=(a*a)%m;}return ans;}
//int binpow(int a,int b){int ans=1;while(b){if(b&1){ans=(ans*a);}b>>=1;a=(a*a);}return ans;}
const int N = 2e5 + 10, inf = 1e18;
main(){
iostream::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int32_t 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 = -inf;
for(int i = 0; i < (1 << n); i++){
for(int j = 0; j < (1 << n); j++){
long double suma = 0, sumb = 0;
for(int l = 0; l < n; l++){
if(i & (1 << l))
suma += a[l];
if(j & (1 << l))
sumb += b[l];
}
ans = max(ans, min(suma, sumb) - __builtin_popcount(i) - __builtin_popcount(j));
}
}
printf("%.4lf",(double)ans);
}
Compilation message
sure.cpp:17:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
17 | main(){
| ^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
69 ms |
444 KB |
Output is correct |
4 |
Correct |
68 ms |
348 KB |
Output is correct |
5 |
Correct |
68 ms |
440 KB |
Output is correct |
6 |
Correct |
69 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
69 ms |
444 KB |
Output is correct |
4 |
Correct |
68 ms |
348 KB |
Output is correct |
5 |
Correct |
68 ms |
440 KB |
Output is correct |
6 |
Correct |
69 ms |
348 KB |
Output is correct |
7 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
69 ms |
444 KB |
Output is correct |
4 |
Correct |
68 ms |
348 KB |
Output is correct |
5 |
Correct |
68 ms |
440 KB |
Output is correct |
6 |
Correct |
69 ms |
348 KB |
Output is correct |
7 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |