# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
91116 | 2018-12-26T09:57:26 Z | Hideo | Bank (IZhO14_bank) | C++14 | 42 ms | 528 KB |
#include <bits/stdc++.h> #define mk make_pair using namespace std; const int N = 25; int dp[N][1 << 16], a[N], b[N], sum[1 << 16]; int n, m; main(){ cin >> n >> m; for (int i = 1; i <= n; i++){ scanf ("%d", &a[i]); } for (int i = 1; i <= m; i++){ scanf ("%d", &b[i]); } for (int mask = 0; mask < (1 << m); mask++){ for (int i = 1; i <= m; i++){ if (mask << (i - 1)){ sum[mask] += b[i]; } } } dp[0][0] = 1; for (int i = 1; i <= n; i++){ for (int mask1 = 0; mask1 < (1 << m); mask1++){ for (int mask2 = mask1; mask2 > 0; mask2 = mask1 & (mask2 - 1)){ if (dp[i - 1][mask1 - mask2] == 1 && sum[mask2] == a[i]){ dp[i][mask1] = 1; break; } } } } for (int mask = 0; mask < (1 << m); mask++){ if (dp[n][mask]){ cout << "YES"; return 0; } } cout << "NO"; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 508 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 42 ms | 528 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |