#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ll n,m;
cin>>n>>m;
vector<ll>salary(n);
vector<ll>chiquis(m);
ll suma=0;
for(ll i=0;i<n;i++){
cin>>salary[i];
}
for(ll i=0;i<m;i++){
cin>>chiquis[i];
suma+=chiquis[i];
}
vector<bool>dp(suma+1,false);
dp[0]=true;
for(ll i=1;i<=suma;i++){
for(ll j=0;j<m;j++){
if(chiquis[j]<=i){
dp[i]=dp[i-chiquis[j]];
}
}
}
bool si=true;
for(ll i=0;i<n;i++){
if(!dp[salary[i]]){
si=false;
break;
}
}
if(si){
cout<<"YES\n";
}
else{
cout<<"NO\n";
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |