#include <iostream>
using namespace std;
const int N = 21;
int n, m, a[N], b[N];
bool dp[N][N*1001];
int main(){
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][0] = 1;
for (int i = 0; i < m; ++i){
for (int val = 0; val < 1001*N; ++val){
dp[i+1][val] |= dp[i][val];
dp[i+1][val+b[i+1]] |= dp[i][val];
}
}
bool ans = 0;
for (int i = 1; i <= m; ++i){
ans |= dp[i][a[1]];
}
cout << (ans? "YES" : "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... |