#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
int n;
cin >> n;
vector <pair <double, double>> nums(n);
for (int i = 0; i < n; i++) {
double a, b;
cin >> a >> b;
nums[i].first = a;
nums[i].second = b;
}
double ans = 0;
for (int i = 0; i < (1 << (2 * n)); i++) {
double l = 0, r = 0;
double cnt = __builtin_popcount(i);
for (int j = 0; j < 2*n; j++) {
if (i & (1 << j)) {
if (j % 2 == 0)
l += nums[j/2].first;
else
r += nums[j/2].second;
}
}
ans = max(ans, min(l, r) - cnt);
}
printf("%.4lf", ans);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
59 ms |
344 KB |
Output is correct |
4 |
Correct |
58 ms |
348 KB |
Output is correct |
5 |
Correct |
58 ms |
348 KB |
Output is correct |
6 |
Correct |
58 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
59 ms |
344 KB |
Output is correct |
4 |
Correct |
58 ms |
348 KB |
Output is correct |
5 |
Correct |
58 ms |
348 KB |
Output is correct |
6 |
Correct |
58 ms |
344 KB |
Output is correct |
7 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
59 ms |
344 KB |
Output is correct |
4 |
Correct |
58 ms |
348 KB |
Output is correct |
5 |
Correct |
58 ms |
348 KB |
Output is correct |
6 |
Correct |
58 ms |
344 KB |
Output is correct |
7 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |