Submission #906639

#TimeUsernameProblemLanguageResultExecution timeMemory
906639zhasynBank (IZhO14_bank)C++14
19 / 100
1 ms464 KiB
#include <bits/stdc++.h>
#define pb push_back
#define pf push_front
using namespace std;
#define F first
#define S second
typedef long long ll;
#define pii pair <int, int>
#define pll pair <ll, ll>
typedef long double ld;
const ll N = 2500 + 10;
const ll mod = 998244353;

ll um(ll a, ll b){
	return ((1LL * a * b) % mod + mod) % mod;
}
ll subr(ll a, ll b){
	return ((1LL * a - b) % mod + mod) % mod;
}
int a[N], b[N];
bool dp[N];
int main() {
	ios::sync_with_stdio(false);
  	cin.tie(NULL);
  	//freopen("bank.in", "r", stdin);
  	//freopen("bank.out", "w", stdout);
  	int n, m;
  	cin >> n >> m;
  	for(int i = 0; i < n; i++){
  		cin >> a[i];
  	}
  	for(int i = 0; i < m; i++){
  		cin >> b[i];
  	}
  	dp[0] = true;
  	for(int i = 0; i < m; i++){
  		for(int j = a[0]; j >= b[i]; j--){
  			dp[j] |= dp[j - b[i]];
  		}
  	}
  	if(dp[a[0]]) cout << "YES";
  	else cout << "NO";
  return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...