#include <bits/stdc++.h>
#define speed ios_base::sync_with_stdio(0);cin.tie(0)
#define sz size()
#define all(x) x.begin(),x.end()
#define pb push_back
#define F first
#define S second
#define int long long
#define revs reverse
#define FOR(in,fr,to,pl) for(int in=fr;in<=to;in+=pl)
#define FORR(in,fr,to,pl) for(int in=fr;in>=to;in-=pl)
#define ld long double
using namespace std;
const int maxn=2e5+19,inf=1e9,mod=1000003;
int a[maxn], b[maxn], dp[maxn];
signed main(){
speed;
int t;
t=1;
while(t--){
int n, m;
cin >> n >> m;
int mx=0;
FOR(i,1,n,1){
cin >> a[i];
mx=max(mx, a[i]);
}
FOR(i,1,mx,1)dp[i]=0;
FOR(i,1,m,1){
cin >> b[i];
dp[b[i]]=1;
}
dp[0]=1;
FOR(i,1,mx,1){
FOR(j,1,m,1){
if(i-b[j]>=0){
if(dp[i-b[j]]){
dp[i]=1;
break;
}
}
}
}
bool ynn=1;
FOR(i,1,mx,1){
cout << dp[i] <<' ';
}
if(ynn)cout << "YES\n";
else cout << "NO\n";
}
return 0;
}
| # | 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... |