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[20005];
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];
}
dp[0]=1;
for(int i=1;i<=m;++i) {
for(int j=b[i];j<=20000;++j) {
if(dp[j-b[i]]) {
dp[j]=1;
}
}
}
if(dp[a[1]]) {
cout << "YES";
} else {
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... |