# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
37781 |
2017-12-28T06:06:43 Z |
Talant |
Bank (IZhO14_bank) |
C++14 |
|
18 ms |
868 KB |
#include <bits/stdc++.h>
#define fr first
#define sc second
#define OK puts("OK");
#define pb push_back
#define mk make_pair
using namespace std;
typedef long long ll;
const ll inf = (ll)1e18 + 7;
const ll N = (ll)1e6 + 7;
int n,m;
int a[21],b[21];
int dp[21][1 << 20];
int t[1 << 20];
int main () {
cin >> n >> m;
for (int i = 1; i <= n; i ++)
cin >> a[i];
for (int i = 0; i < m; i ++)
cin >> b[i];
for (int i = 0; i < (1 << m); i ++) {
int sum = 0;
for (int j = 0; j < m; j ++)
if (i & (1 << j))
sum += b[j];
t[i] = sum;
}
dp[1][0] = 1;
for (int i = 1; i <= n; i ++) {
for (int j = 0; j < (1 << m); j ++) {
if (t[j] == b[i]) {
for (int k = 0; k < (1 << m); k ++) {
int o = k;
for (int l = 0; l < m; l ++)
if (j & (1 << l)) {
if (o & (1 << l))
o = (o ^ (1 << l));
else
o = (o & (1 << l));
}
if (dp[i][o] == 1)
dp[i + 1][j] = 1;
}
}
}
}
for (int i = 0; i < (1 << m); i ++) {
if (dp[n + 1][i] == 1) {
cout << "YES" << endl;
return 0;
}
}
cout << "NO" << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
460 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
464 KB |
Output is correct |
2 |
Correct |
2 ms |
464 KB |
Output is correct |
3 |
Correct |
2 ms |
464 KB |
Output is correct |
4 |
Incorrect |
2 ms |
560 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
644 KB |
Output is correct |
2 |
Correct |
3 ms |
720 KB |
Output is correct |
3 |
Correct |
5 ms |
736 KB |
Output is correct |
4 |
Incorrect |
18 ms |
868 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
460 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |