This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |