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;
bool kiki=0;
void baraj(int pari[], int i, int plata, int suma, int m)
{
if(suma==plata)
{
kiki=1;
return;
}
if(i==m)
return;
if(suma+pari[i]<=plata)
baraj(pari, i+1, plata, suma+pari[i], m);
baraj(pari, i+1, plata, suma, m);
}
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 pari[m];
for(int i=0; i<m; i++)
{
cin>>pari[i];
}
baraj(pari, 0, plata[0], 0, m);
if(kiki)
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... |