# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
758641 | KN200711 | Bank (IZhO14_bank) | C++14 | 1080 ms | 44612 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 <bits/stdc++.h>
using namespace std;
map<int, vector<int> > ck;
int nd[1000001];
set<int> dp[21];
int main() {
int N, M;
scanf("%d %d", &N, &M);
vector<int> A(N), B(M);
for(int i=0;i<N;i++) {
scanf("%d", &A[i]);
nd[A[i]] = 1;
}
for(int i=0;i<M;i++) {
scanf("%d", &B[i]);
}
for(int i=0;i<(1 << M);i++) {
int sum = 0;
for(int k=0;k<M;k++) {
if(i&(1 << k)) sum += B[k];
}
if(sum <= 1e6 && nd[sum]) ck[sum].push_back(i);
}
dp[0].insert(0);
for(int i=0;i<N;i++) {
for(auto p : dp[i]) {
for(auto k : ck[A[i]]) {
if(p&k) continue;
dp[i + 1].insert(p|k);
}
}
}
if(dp[N].size()) printf("YES\n");
else printf("NO\n");
return 0;
}
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... |