This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsigned long long
#define pb push_back
#define pob pop_back
//#define int long long
#define int2 __int128_t
#define Shrek_Crush228 ios_base::sync_with_stdio(0), cin.tie(0);
#define F first
#define S second
#define FOR( i, x, n, d ) for( int i = x; i <= n; i += d )
#define FORR( i, x, n, d ) for( int i = x; i >= n; i -= d )
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define no cout << "NO\n"
#define yes cout << "YES\n"
#define nep next_permutation
#define sigma signed
#define pii pair <int, int>
using namespace std;
string alp = "abcdefghijklmnopqrstuvwxyz";
string ae = "aoeiuy";
string nums = "123456789";
const int N = 1e3 + 123;
const int inf = 1e9;
const int MOD = 1e9 + 7;
const int MOD1 = 998244353;
const long long maxsum = 1e14;
int a[N], b[N], c[N], l, r, n, k, m, w, sum, sum1, y, ans1, mx = -inf, mn = inf, ind, ind1, pref[N], suf[N], nt[N];
string s, s1;
int cnt1, cnt2, cnt3;
vector <int> v;
void rec( int need, int i = 1, int sum = 0, string ss = "" )
{
if( sum == need )
{
s = ss;
return;
}
if( i > m ) return;
if( !nt[i] ) rec( need, i + 1, sum + b[i], ss + '1' );
rec( need, i + 1, sum, ss + '0' );
}
void solve()
{
cin >> n >> m;
FOR( i, 1, n, 1 ) cin >> a[i];
FOR( i, 1, m, 1 ) cin >> b[i];
FOR( i, 1, n, 1 )
{
s = "";
rec( a[i] );
if( s.size() == 0 )
{
cout << "NO";
return;
}
FOR( pos, 0, s.size() - 1, 1 )
{
if( s[pos] == '1' ) nt[pos] = 1;
}
}
cout << "YES";
}
sigma main()
{
//freopen("rmq.in", "r", stdin);
//freopen("rmq.out", "w", stdout);
Shrek_Crush228
int test = 1;
if( !test ) cin >> test;
while( test -- )
{
solve();
}
}
// solved by KluydQ
Compilation message (stderr)
bank.cpp: In function 'void solve()':
bank.cpp:16:45: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
16 | #define FOR( i, x, n, d ) for( int i = x; i <= n; i += d )
......
74 | FOR( pos, 0, s.size() - 1, 1 )
| ~~~~~~~~~~~~~~~~~~~~
bank.cpp:74:3: note: in expansion of macro 'FOR'
74 | FOR( pos, 0, s.size() - 1, 1 )
| ^~~
# | 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... |