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 int long long
#define oo 100000000000
const int sz=21;
int a[sz],b[sz];
bool dp[1005];
signed main() {
ios::sync_with_stdio(false); cin.tie(0);
int n,m; cin >> n >> m;
for(int i=1;i<=n;++i) {
cin >> a[i];
}
for(int i=1;i<=m;++i) {
cin >> b[i];
}
for(int mask=0;mask<(1<<m);++mask){
int sum=0;
for(int i=0;i<m;++i) {
if(mask>>i&1) {
sum += b[i+1];
}
}
if(sum==a[1]) {
return cout<<"YES",0;
}
}
cout << "NO";
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... |