#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using pii = pair<int,int>;
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,avx2,mmx,fma,avx,tune=native")
const int N = 200'000, inf = 1'000'000'000;
const i64 infl = 1'000'000'000'000'000'000;
const int mod1 = 1'000'000'009, mod2 = 998'244'353;
const int p1 = 31, p2 = 37;
#define ff first
#define ss second
#define pb push_back
#define ins insert
#define sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define NO cout << "NO\n"
#define YES cout << "YES\n"
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int __tc = 1;
int n, m;
int a[N+5], b[N+5];
void solve() {
if (n == 1) {
int x = a[1];
for (int P = 1; P < (1 << m); P++) {
int s = 0;
for (int i = 1; i <= m; i++) {
if ((P >> (i - 1)) & 1) s += b[i];
}
if (s == x) { YES; return; }
}
NO;
return;
}
}
int main() {
ios_base::sync_with_stdio(false); cin.tie(nullptr);
// cin >> __tc;
for (int _tc = 1; _tc <= __tc; _tc++) {
cin >> n >> m;
for (int i = 1; i <= n; i++) cin >> a[i];
for (int j = 1; j <= m; j++) cin >> b[j];
solve();
}
}
// m <= 20
# | 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... |