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 fast ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0)
#define endl '\n'
#define int long long
#define f first
#define mp make_pair
#define s second
using namespace std;
int n, m;
int p[20], b[20];
signed main()
{
fast;
cin >> n >> m;
for(int i = 0; i < n; i++) cin >> p[i];
for(int i = 0; i < m; i++) cin >> b[i];
bool ans = false;
for(int msk = 0; msk < (1 << m); msk++){
int add = 0;
for(int i = 0; i < m; i++) if(msk & (1 << i)) add += b[i];
if(add == p[0]) ans = true;
}
cout << (ans ? "YES" : "NO") << endl;
}
# | 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... |