# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1085780 | Sunbae | Bank (IZhO14_bank) | C++17 | 1072 ms | 8624 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <cstdio>
#include <string>
#include <algorithm>
using namespace std;
int dp[1<<20], s[1<<20];
int a[20], b[20];
int M[20][1<<20], sz[20];
signed main(){
int n, m; scanf("%d %d", &n, &m);
for(int i = 0; i<n; ++i) scanf("%d", a+i);
for(int i = 0; i<m; ++i) scanf("%d", b+i);
int lim = 1<<m;
for(int mk = 0; mk<lim; ++mk){
for(int j = 0; j<m; ++j) s[mk] += (mk>>j&1) * b[j];
dp[mk] |= (s[mk] == a[0]);
for(int i = 1; i<n; ++i) if(s[mk] == a[i]) M[i][sz[i]++] = mk;
}
for(int i = 1; i<n; ++i){
for(int mk = lim-1; mk>=0; --mk){
dp[mk] = 0;
for(int j = 0; j<sz[i]; ++j){
int k = M[i][j];
if((mk & k) == k) dp[mk] |= dp[mk ^ k];
}
}
}
(*max_element(dp, dp+lim)) ? puts("YES") : puts("NO");
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |