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 ff first
#define ss second
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
const int N = 100001;
int dp[N];
signed main(){
ios::sync_with_stdio(0); cin.tie(0);
int n, m; cin >> n >> m;
int A[n];
for(int i = 0; i < n; i++) {
cin >> A[i];
}
int M[m];
for(int i = 0; i < m; i++)
cin >> M[i];
dp[0] = 1;
for(int i = 1; i <= 10000; i++) {
for(int j = 0; j < m; j++) {
if(i - M[j] >= 0) {
dp[i] = dp[i - M[j]];
}
}
}
if(accumulate(dp, dp + N, 0) == n)
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... |