Submission #938247

#TimeUsernameProblemLanguageResultExecution timeMemory
938247vjudge1Sure Bet (CEOI17_sure)C++17
20 / 100
68 ms428 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...