//
// Created by liasa on 25/11/2025.
//
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define v vector
#define lp(i, s, e) for (int i = s; i < e; ++i)
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, m;
cin >> n >> m;
v<int> a(n), b(m);
lp(i, 0, n) cin >> a[i];
lp(i, 0, m) cin >> b[i];
ll val = a[0];
ll mx = 1005;
v<int> dp(mx);
dp[0] = 1;
for (auto it : b) {
for (int i = mx-1; i>=0 ;--i){
if (i - it >= 0 && dp[i - it] == 1)
dp[i] = 1;
}
}
ll ans = dp[val];
cout << (ans ? "YES" : "NO");
}
| # | 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... |