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;
const int N=22;
int a[N], b[N];
int main() {
int n,m;
cin>>n>>m;
bool flag=false;
for(int i=1; i<=n; i++)
cin>>a[i];
for(int i=1; i<=m; i++)
cin>>b[i];
for(int i=1; i<(1<<m); i++){
long long ans=0;
for(int j=0; j<m; j++){
if(i & (1<<j)){
ans+=b[j];
}
}
if(ans==a[1]){
flag=true;
break;
}
ans=0;
}
if(!flag){
cout<<"NO"<<"\n";
return 0;
}
cout<<"YES"<<"\n";
}
# | 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... |