제출 #1325560

#제출 시각아이디문제언어결과실행 시간메모리
1325560csachy13은행 (IZhO14_bank)C++20
44 / 100
57 ms440 KiB
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = long double;

int main() {
	cin.tie(0); ios_base::sync_with_stdio(0);
	
	ll N, M;
	cin >> N >> M;
	
	// greedy/brute force bogus solution: small to large
	vector<ll> X(N), Y(M);
	for (int i=0; i<N; i++) cin >> X[i];
	for (int i=0; i<M; i++) cin >> Y[i];
	
	sort(X.rbegin(), X.rend());
	sort(Y.rbegin(), Y.rend());
	
	// bool bad = 0;
	bool found = 0;
	for (int i=0; i<N; i++) {
		found = 0; int j = 0;
		for (j=0; j<1<<M; j++) {
			ll sum = 0;
			for (int k=0; k<M; k++) {
				if ((j >> k) & 1) sum += Y[k];
			}
			if (sum == X[i]) {
				found = 1;
				break;
			}
		}
		
		if (!found) {
			cout << "NO\n";
			return 0;
		}
		
		for (int k=0; k<M; k++) {
			if ((j >> k) & 1) Y[k] = 100000;
		}
	}
	
	cout << "YES\n";
	
	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...