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;
int main()
{
int n, m;
cin>>n>>m;
int plata[n];
for(int i=0; i<n; i++)
{
cin>>plata[i];
}
if(n==1)
{
int dp[1003], pari[m];
for(int i=0; i<1003; i++)
dp[i]=i;
for(int i=0; i<m; i++)
{
cin>>pari[i];
dp[pari[i]]=0;
}
for(int i=1; i<=plata[0]; i++)
{
if(!dp[i])
continue;
for(int j=0; j<m; j++)
{
if(i-pari[j]>=1)
{
dp[i]=min(dp[i], dp[i-pari[j]]);
}
}
}
if(dp[plata[0]==0])
cout<<"YES";
else
cout<<"NO";
}
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... |