# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
441932 |
2021-07-06T15:00:51 Z |
tht2005 |
Bank (IZhO14_bank) |
C++17 |
|
343 ms |
205580 KB |
#include <bits/stdc++.h>
using namespace std;
#define nmax 25
int n, m, a[nmax], b[nmax], f[nmax][1<<21];
int dp(int i, int mask, int64_t sum)
{
if(f[i][mask] != -1)
return f[i][mask];
if(i >= n)
return f[i][mask] = 1;
f[i][mask] = 0;
for(int t = 0; t < m; ++t) {
if((mask >> t) & 1) continue;
if(sum + b[t] < a[i]) {
if(dp(i, mask | (1 << t), sum + b[t])) f[i][mask] = 1;
}
else if(sum + b[t] == a[i]) {
if(dp(i + 1, mask | (1 << t), 0)) f[i][mask] = 1;
}
}
return f[i][mask];
}
int main()
{
ios::sync_with_stdio(false); cin.tie(NULL);
cin >> n >> m;
for(int i = 0; i < n; ++i)
cin >> a[i];
for(int i = 0; i < m; ++i)
cin >> b[i];
memset(f, -1, sizeof(f));
cout << (dp(0, 0, 0) ? "YES" : "NO") << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
105 ms |
205480 KB |
Output is correct |
2 |
Correct |
102 ms |
205456 KB |
Output is correct |
3 |
Correct |
104 ms |
205448 KB |
Output is correct |
4 |
Correct |
106 ms |
205380 KB |
Output is correct |
5 |
Correct |
105 ms |
205436 KB |
Output is correct |
6 |
Correct |
104 ms |
205432 KB |
Output is correct |
7 |
Correct |
106 ms |
205508 KB |
Output is correct |
8 |
Correct |
193 ms |
205488 KB |
Output is correct |
9 |
Correct |
230 ms |
205492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
105 ms |
205380 KB |
Output is correct |
2 |
Correct |
109 ms |
205540 KB |
Output is correct |
3 |
Correct |
103 ms |
205456 KB |
Output is correct |
4 |
Correct |
106 ms |
205508 KB |
Output is correct |
5 |
Correct |
103 ms |
205376 KB |
Output is correct |
6 |
Correct |
103 ms |
205384 KB |
Output is correct |
7 |
Correct |
104 ms |
205432 KB |
Output is correct |
8 |
Correct |
106 ms |
205464 KB |
Output is correct |
9 |
Correct |
105 ms |
205384 KB |
Output is correct |
10 |
Correct |
104 ms |
205480 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
105 ms |
205404 KB |
Output is correct |
2 |
Correct |
105 ms |
205496 KB |
Output is correct |
3 |
Correct |
108 ms |
205380 KB |
Output is correct |
4 |
Correct |
107 ms |
205492 KB |
Output is correct |
5 |
Correct |
106 ms |
205372 KB |
Output is correct |
6 |
Correct |
105 ms |
205380 KB |
Output is correct |
7 |
Correct |
106 ms |
205400 KB |
Output is correct |
8 |
Correct |
102 ms |
205440 KB |
Output is correct |
9 |
Correct |
105 ms |
205380 KB |
Output is correct |
10 |
Correct |
110 ms |
205436 KB |
Output is correct |
11 |
Correct |
107 ms |
205512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
105 ms |
205480 KB |
Output is correct |
2 |
Correct |
102 ms |
205456 KB |
Output is correct |
3 |
Correct |
104 ms |
205448 KB |
Output is correct |
4 |
Correct |
106 ms |
205380 KB |
Output is correct |
5 |
Correct |
105 ms |
205436 KB |
Output is correct |
6 |
Correct |
104 ms |
205432 KB |
Output is correct |
7 |
Correct |
106 ms |
205508 KB |
Output is correct |
8 |
Correct |
193 ms |
205488 KB |
Output is correct |
9 |
Correct |
230 ms |
205492 KB |
Output is correct |
10 |
Correct |
105 ms |
205380 KB |
Output is correct |
11 |
Correct |
109 ms |
205540 KB |
Output is correct |
12 |
Correct |
103 ms |
205456 KB |
Output is correct |
13 |
Correct |
106 ms |
205508 KB |
Output is correct |
14 |
Correct |
103 ms |
205376 KB |
Output is correct |
15 |
Correct |
103 ms |
205384 KB |
Output is correct |
16 |
Correct |
104 ms |
205432 KB |
Output is correct |
17 |
Correct |
106 ms |
205464 KB |
Output is correct |
18 |
Correct |
105 ms |
205384 KB |
Output is correct |
19 |
Correct |
104 ms |
205480 KB |
Output is correct |
20 |
Correct |
105 ms |
205404 KB |
Output is correct |
21 |
Correct |
105 ms |
205496 KB |
Output is correct |
22 |
Correct |
108 ms |
205380 KB |
Output is correct |
23 |
Correct |
107 ms |
205492 KB |
Output is correct |
24 |
Correct |
106 ms |
205372 KB |
Output is correct |
25 |
Correct |
105 ms |
205380 KB |
Output is correct |
26 |
Correct |
106 ms |
205400 KB |
Output is correct |
27 |
Correct |
102 ms |
205440 KB |
Output is correct |
28 |
Correct |
105 ms |
205380 KB |
Output is correct |
29 |
Correct |
110 ms |
205436 KB |
Output is correct |
30 |
Correct |
107 ms |
205512 KB |
Output is correct |
31 |
Correct |
219 ms |
205380 KB |
Output is correct |
32 |
Correct |
275 ms |
205548 KB |
Output is correct |
33 |
Correct |
115 ms |
205524 KB |
Output is correct |
34 |
Correct |
108 ms |
205372 KB |
Output is correct |
35 |
Correct |
107 ms |
205444 KB |
Output is correct |
36 |
Correct |
105 ms |
205380 KB |
Output is correct |
37 |
Correct |
107 ms |
205464 KB |
Output is correct |
38 |
Correct |
109 ms |
205508 KB |
Output is correct |
39 |
Correct |
146 ms |
205380 KB |
Output is correct |
40 |
Correct |
107 ms |
205376 KB |
Output is correct |
41 |
Correct |
106 ms |
205476 KB |
Output is correct |
42 |
Correct |
179 ms |
205580 KB |
Output is correct |
43 |
Correct |
106 ms |
205408 KB |
Output is correct |
44 |
Correct |
113 ms |
205424 KB |
Output is correct |
45 |
Correct |
176 ms |
205424 KB |
Output is correct |
46 |
Correct |
130 ms |
205440 KB |
Output is correct |
47 |
Correct |
104 ms |
205452 KB |
Output is correct |
48 |
Correct |
132 ms |
205420 KB |
Output is correct |
49 |
Correct |
103 ms |
205380 KB |
Output is correct |
50 |
Correct |
308 ms |
205492 KB |
Output is correct |
51 |
Correct |
106 ms |
205416 KB |
Output is correct |
52 |
Correct |
115 ms |
205380 KB |
Output is correct |
53 |
Correct |
295 ms |
205412 KB |
Output is correct |
54 |
Correct |
343 ms |
205508 KB |
Output is correct |
55 |
Correct |
310 ms |
205492 KB |
Output is correct |
56 |
Correct |
341 ms |
205492 KB |
Output is correct |
57 |
Correct |
332 ms |
205492 KB |
Output is correct |
58 |
Correct |
341 ms |
205500 KB |
Output is correct |