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;
#define int long long
#define all(x) x.begin(), x.end()
#define size(x) (int)x.size()
template<class S, class T>
bool chmin(S &a, const T &b) {
return a > b ? (a = b) == b : false;
}
template<class S, class T>
bool chmax(S &a, const T &b) {
return a < b ? (a = b) == b : false;
}
signed main() {
cin.tie(nullptr)->sync_with_stdio(false);
int n; cin >> n;
double a[n], b[n];
for (int i = 0; i < n; ++i) {
cin >> a[i] >> b[i];
}
double res = 0;
for (int mask = 0; mask < (1 << (n << 1)); ++mask) {
double f = 0, s = 0;
for (int i = 0, bit = 0; i < n; ++i, bit += 2) {
if (mask >> bit & 1) f += a[i];
if (mask >> (bit + 1) & 1) s += b[i];
}
chmax(res, min(f, s) - __builtin_popcount(mask));
}
cout << fixed << setprecision(4) << res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |