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>
using namespace std;
#define int long long
#define sz(x) x.size()
#define pb push_back
#define F first
#define S second
#define nl '\n'
const int N = 3e5 + 1;
const int inf = 1e12;
const int mod = 1e9 + 7;
void solve()
{
int n, m;
cin >>n >>m;
int a[n], b[m];
for( int i = 0; i < n; ++i )
cin >>a[i];
for( int j = 0; j < m; ++j )
cin >>b[j];
for( int mask = 0; mask < (1 << m); ++mask )
{
int sum = 0;
for( int j = 0; j < m; ++j )
if( (1 << j) & mask )
sum += b[j];
if( sum == a[0] )
{
cout <<"YES\n";
return;
}
}
cout <<"NO\n";
}
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
int T = 1;
// cin >>T;
while( T-- )
solve();
}
# | 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... |