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>
typedef long long ll;
using namespace std;
int n, m;
int a[25], b[25];
set<int> st;
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n >> m;
for(int i=0; i<n; i++) cin>>a[i];
for(int i=0; i<m; i++) cin>>b[i];
for(int i=1; i<(1<<m); i++){
int i2 = i, tmp=0;
for(int j=0; j<m; j++){
if((i2 & (1<<j)) != 0) tmp += b[j];
}
st.insert(tmp);
}
bool flag = 1;
for(int i=0; i<n; i++){
if(!st.count(a[i])){
flag = 0;
}
}
if(flag) cout<<"YES\n";
else cout<<"NO\n";
return 0;
}
# | 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... |