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;
using ll = long long;
void solve(){
int n,m;
cin>>n>>m;
vector<int>a(n);
vector<int>b(m);
for(int &i:a){
cin>>i;
}
for(int &i:b){
cin>>i;
}
vector<int>dp(1005);
dp[0]=1;
for(int i = 0;i<m;i++){
for(int j = 0;j<=1000;j++){
int x = b[i]+j;
if(x<=1000){
if(dp[j]==1){
dp[x]=1;
}
}
}
}
if(dp[a[0]]==1){
cout<<"YES"<<endl;
}
else{
cout<<"NO"<<endl;
}
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(nullptr);
// ll t;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... |