제출 #1171418

#제출 시각아이디문제언어결과실행 시간메모리
1171418SG2Alok은행 (IZhO14_bank)C++20
0 / 100
3 ms584 KiB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;
#define endl '\n'
#define hitaf ios_base::sync_with_stdio(false); cin.tie(0);
#define fi first
#define se second
 
template <typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag, tree_order_statistics_node_update>;
 
const ll MOD1 = 1e9 + 7;
const ll MOD = 998244353;
const ll INF = 4500000000000000000LL;
const ll mod1 = 6900000469;
const ll mod2 = 698000002369;
const int block = 447;
 
ll n, m, k, q, a[1200005], b[500005], c[500005];
string s, s1, s2;
bool dp[200005];

int main(){
	hitaf
	int T = 1;
//	cin >> T;
	
	while(T--){
		cin >> n >> m;
		
		for(int i = 1; i <= n; i++) cin >> a[i];
		for(int i = 1; i <= m; i++) cin >> b[i];
		
		dp[0] = true;
		for(int i = 1; i <= m; i++){
			for(int j = 1; j <= 2e5; j++){
				if(j >= b[i]){
					dp[j] |= dp[j - a[i]];
				}
			}
		}
		
		dp[a[1]]  ? cout << "YES" << endl : cout << "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...