Submission #870879

#TimeUsernameProblemLanguageResultExecution timeMemory
870879sleepntsheepBank (IZhO14_bank)C++17
0 / 100
28 ms33768 KiB
#include <iostream> #include <cstring> #include <vector> #include <algorithm> #include <deque> #include <set> #include <utility> #include <array> using namespace std; #define ALL(x) x.begin(), x.end() #define ShinLena cin.tie(nullptr)->sync_with_stdio(false); using i64 = long long; int z=4, n, m, a[23], b[22], dp[2][1<<21]; int main() { ShinLena; cin >> n >> m; memset(dp, 0x86, sizeof dp); for (int i = 1; i <= n; ++i) cin >> a[i]; for (int i = 0; i < m; ++i) cin >> b[i]; dp[0][0] = 0; for (int i = 0, I = 0; i <= n; ++i, I^=1) { if (i) memset(dp[I], 0x86, sizeof *dp); for (int j = 0; j < (1 << m); ++j) { if (i) if (dp[!I][j] == a[i]) dp[I][j] = 0; for (int k = 0; k < j; ++k) { if (j & (1 << k)) { int p = j&~(1<<k); dp[I][j] = max(dp[I][j], dp[I][p] + b[k]); } } if (i == n && !dp[I][j]) z = 0; } } cout << &"YES\0NO"[z]; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...