# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
37598 | alenam0161 | Bank (IZhO14_bank) | C++14 | 226 ms | 14776 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;
#define ad push_back
const int N = 20;
int n,m;
bool used[N][1<<N];
vector<int> comb[N];
int a[N],b[N];
void rek(int x,int clc){
if(x==n){
cout<<"YES";exit(0);
}
if(used[x][clc]==true)return;
used[x][clc]=true;
for(int to:comb[x]){
if(clc&to)continue;
rek(x+1,clc|to);
}
}
int main(){
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);
for(int i=0;i<(1<<m);++i){
int csum=0;
for(int j=0;j<20;++j)if(i&(1<<j))csum+=b[j];
for(int j=0;j<n;++j)if(csum==a[j]){
comb[j].ad(i);
}
}
rek(0,0);
cout<<"NO"<<endl;
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... |