제출 #1321782

#제출 시각아이디문제언어결과실행 시간메모리
1321782vtnoo은행 (IZhO14_bank)C++20
0 / 100
1 ms332 KiB
#include <bits/stdc++.h>
#define L(i, j, k) for(int i = (j); i <= (k); i++)
#define R(i, j, k) for(int i = (j); i >= (k); i--)
#define ll long long
#define sz(a) ((int) a.size())
#define all(a) a.begin(), a.end()
#define vi vector<ll>
#define pb emplace_back
#define me(a, x) memset(a, x, sizeof(a))
#define fst first
#define snd second
#define ii pair<int, int>
using namespace std;
const int MAXN=2e5+5,LOG=20,INF=1e9;
int main(){
	ios::sync_with_stdio(false); 
	cin.tie(nullptr);
	int n,m;cin>>n>>m;
	vi a(n),b(m);
	L(i,0,n-1)cin>>a[i];
	L(i,0,m-1)cin>>b[i];
	vector<bool>dp(a[0]+1,0);
	dp[0]=1;
	L(i,1,sz(dp)-1){
		L(j,0,m-1){
			if(b[j]<=i)dp[i]=dp[i]|dp[i-b[j]];
		}
	}
	cout<<(dp[a[0]]?"YES":"NO")<<endl;
}

#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...