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() {
bool ans=false;
int n,m,dum; cin >> n >> m;
vector<int> salaries; vector<int> banknotes;
for (int i=0;i<n;i++) {
cin >> dum;
salaries.push_back(dum);
}
for (int i=0;i<m;i++) {
cin >> dum;
banknotes.push_back(dum);
}
int val,icopy,count;
for (int i=0;i<pow(2,m)-1;i++) {
val=0;
icopy=i;
count=0;
while (icopy>0) {
if (icopy%2==1) {
val+=banknotes[count];
}
count++;
icopy>>=1;
}
if (val==salaries[0]) {
ans=true;
break;
}
}
if (ans) {
cout << "YES";
} else {
cout << "NO";
}
}
# | 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... |