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[1000], b[1000];
int main(){
int n,m;
cin >> n >> m;
for(int i=1; i<=n ; i++){
cin >> a[i];
}
for(int i=1; i<=m; i++){
cin >> b[i];
}
int cnt=0;
for(int i=1 ;i<=n; i++){
for(int j=1; j<=m; j++){
next_permutation(b+1, b+m+1);
int sum = 0;
bool k=0;
for(int h=1;h<=m;h++){
sum+=b[h];
if(sum == a[i]){
cnt++;
k=1;
break;
}
}
if(k)break;
}
}
if(cnt == n) cout << "YES";
else {
cout << "NO";
}
}
//SULTAN SKATAL y Minya
# | 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... |