Submission #938247

# Submission time Handle Problem Language Result Execution time Memory
938247 2024-03-05T03:37:28 Z vjudge1 Sure Bet (CEOI17_sure) C++17
20 / 100
68 ms 428 KB
#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
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 67 ms 428 KB Output is correct
4 Correct 68 ms 344 KB Output is correct
5 Correct 68 ms 352 KB Output is correct
6 Correct 68 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 67 ms 428 KB Output is correct
4 Correct 68 ms 344 KB Output is correct
5 Correct 68 ms 352 KB Output is correct
6 Correct 68 ms 348 KB Output is correct
7 Incorrect 1 ms 344 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 67 ms 428 KB Output is correct
4 Correct 68 ms 344 KB Output is correct
5 Correct 68 ms 352 KB Output is correct
6 Correct 68 ms 348 KB Output is correct
7 Incorrect 1 ms 344 KB Output isn't correct
8 Halted 0 ms 0 KB -