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)
{
bool dp[m][plata[0]+1];
int pari[m];
memset(dp, 0, sizeof(dp));
for(int i=0; i<m; i++)
{
dp[i][0]=1;
}
for(int i=0; i<m; i++)
{
cin>>pari[i];
}
for(int i=0; i<m; i++)
{
for(int j=1; j<=plata[0]; j++)
{
if(j-pari[i]>=0)
{
dp[i][j]=dp[i-1][j]||dp[i-1][j-pari[i]];
}
else
dp[i][j]=dp[max(0, i-1)][j];
}
}
if(dp[m-1][plata[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... |