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>
#define speed ios_base::sync_with_stdio(0), cin.tie(0)
#define int long long
#define st first
#define nd second
#define pb push_back
#define love our_kolhoz
using namespace std;
const int N = 1e5 + 10, inf = 1e18, mod = 1e9 + 7;
//koz qorqaq
int n, m;
void solve() {
cin >> n >> m;
int a[n], b[m];
for (int i = 0; i < n; i++) {
cin >> a[i];
}
for (int i = 0; i < m; i++) {
cin >> b[i];
}
if (n == 1) {
for (int i = 0; i < (1 << m); i++) {
int kek = 0;
for (int j = 0; j < m; j++) {
if (i & (1 << j)) {
kek += (b[j]);
}
}
if (kek == a[0]) {
cout << "YES";
return;
}
}
cout << "NO";
}
}
signed main() {
speed;
//freopen("points.in ", "r", stdin);
//freopen("points.out", "w", stdout);
int _t = 1;
//cin >> _t;
while (_t--)
solve();
return 0;
}
// sau bol
// there's really no way of winning
// if in their eyes you'll always be a dumb blonde...
# | 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... |