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 a[25],b[25],n,m;
bool can[20200];
int main(){
cin >> n >> m;
for(int i = 1; i <= n; ++i){
cin >> a[i];
}
for(int i = 1; i <= m; i++){
cin >> b[i];
}
can[0] = 1;
for(int i = 1; i <= m; i++){
for(int j = 20000; j >= 0; j--){
if(can[j]){
can[j + b[i]] = 1;
}
}
}
for(int i = 1; i <= n; i++){
if(!can[a[i]]){
cout << "NO";
return 0;
}
}
cout << "YES";
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... |