# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1128175 | ImperialALEN | 은행 (IZhO14_bank) | C11 | 0 ms | 0 KiB |
// #pragma GCC optomize ("Ofast")
// #pragma GCC optomize ("unroll-loops")
// #pragma GCC target ("avx,avx2,fma")
//#include <bits/stdc++.h>
#include<iostream>
#include<map>
#include<set>
#define F first
#define S second
#define ll long long
#define int long long
#define pb push_back
#define all(x) (x.begin(),x.end())
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const ll N = 2e5+9, INF = 1e18 , inf = 1e9 , mod = 1e9+7;
int a[22];
int b[22];
int dp[N];
map<int,int>mp;
signed main(){
// freopen("bank.in", "r", stdin);
// freopen("bank.out", "w", stdout);
ios;
int n,m;
cin>>n>>m;
for(int i=1;i<=n;i++)cin>>a[i];
int x=0;
for(int i=1;i<=m;i++){
cin>>b[i];
x+=b[i];
}
if(n==1){
set<int>st;
for(int i=1;i<=m;i++){
for(int pos=x;pos>=1;pos--){
if(pos-b[i]>=0){
dp[pos]=max(dp[pos],dp[pos-b[i]]+b[i]);
st.insert(dp[pos]);
}
}
}
for(auto to:st)mp[to]++;
if(mp[a[1]]!=0)cout<<"YES\n";
else cout<<"NO\n";
}
}