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 n,m;
const int MAX=20;
int plata[MAX],pari[MAX];
int main()
{
cin>>n>>m;
for(int i=0; i<n; i++)cin>>plata[i];
for(int i=0; i<m; i++)cin>>pari[i];
for(int mask=0; mask<(1<<m); mask++)
{
int cnt=0;
for(int i=0; i<m; i++)
{
if(mask&(1<<i))cnt+=pari[i];
if(cnt==plata[0])
{
cout<<"YES"<<endl;
return 0;
}
}
}
cout<<"NO"<<endl;
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... |