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 REP(a,b,c) for(int a=b;a<c;a++)
#define F first
#define S second
#define PB push_back
#define LSOne(s) ((s)&(-s))
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<ll,int> pi;
typedef vector<pi> pii;
ll M=1000000007;
ll INF=1000000000000000010;
int inf=1000000010;
int main(){
int n,m;cin>>n>>m;
vi a(n),b(m);
REP(i,0,n)cin>>a[i];
REP(i,0,m)cin>>b[i];
vi dp(a[0]+1,0);
dp[0]=1;
REP(j,0,m)for(int i=a[0];i>=0;i--)if(dp[i]==1&&i+j<=a[0])dp[i+j]=1;
if(dp[a[0]]==1)cout<<"YES\n";
else cout<<"NO\n";
}
# | 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... |