# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
91118 | 2018-12-26T09:58:39 Z | Hideo | Bank (IZhO14_bank) | C++14 | 1000 ms | 4568 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 & (1 << (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 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 472 KB | Output is correct |
3 | Correct | 2 ms | 472 KB | Output is correct |
4 | Correct | 20 ms | 672 KB | Output is correct |
5 | Execution timed out | 1076 ms | 4568 KB | Time limit exceeded |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 4568 KB | Output is correct |
2 | Correct | 2 ms | 4568 KB | Output is correct |
3 | Correct | 2 ms | 4568 KB | Output is correct |
4 | Correct | 2 ms | 4568 KB | Output is correct |
5 | Correct | 2 ms | 4568 KB | Output is correct |
6 | Correct | 2 ms | 4568 KB | Output is correct |
7 | Correct | 2 ms | 4568 KB | Output is correct |
8 | Correct | 2 ms | 4568 KB | Output is correct |
9 | Correct | 2 ms | 4568 KB | Output is correct |
10 | Correct | 2 ms | 4568 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 42 ms | 4568 KB | Output is correct |
2 | Correct | 20 ms | 4568 KB | Output is correct |
3 | Correct | 59 ms | 4568 KB | Output is correct |
4 | Correct | 82 ms | 4568 KB | Output is correct |
5 | Correct | 59 ms | 4568 KB | Output is correct |
6 | Correct | 30 ms | 4568 KB | Output is correct |
7 | Correct | 25 ms | 4568 KB | Output is correct |
8 | Correct | 19 ms | 4568 KB | Output is correct |
9 | Correct | 48 ms | 4568 KB | Output is correct |
10 | Correct | 48 ms | 4568 KB | Output is correct |
11 | Correct | 81 ms | 4568 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 472 KB | Output is correct |
3 | Correct | 2 ms | 472 KB | Output is correct |
4 | Correct | 20 ms | 672 KB | Output is correct |
5 | Execution timed out | 1076 ms | 4568 KB | Time limit exceeded |
6 | Halted | 0 ms | 0 KB | - |