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;
vector<int> a, b, vis;
int n, m;
void f(int cnt){
if(cnt == m - 1){
int sum = 0;
for(int i = 0; i < m; ++i)
if(vis[i])
sum += b[i];
if(sum == a.front()){
cout << "YES" << "\n";
exit(0);
}
return;
}
for(int i = 0; i <= 1; ++i){
vis[cnt] = i;
f(cnt + 1);
}
}
int main(){
cin >> n >> m;
a.resize(n);
b.resize(m);
for(int &i : a)
cin >> i;
for(int &i : b)
cin >> i;
if(n == 1 and m <= 20){
vis.assign(m, 0);
f(0);
cout << "NO" << "\n";
}
else
cout << "yok" << "\n";
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... |