제출 #1013050

#제출 시각아이디문제언어결과실행 시간메모리
1013050aufan은행 (IZhO14_bank)C++17
71 / 100
1058 ms211604 KiB
#include <bits/stdc++.h> #define int long long #define fi first #define se second using namespace std; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, m; cin >> n >> m; vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i]; vector<int> b(m); for (int i = 0; i < m; i++) cin >> b[i]; vector<int> sum(1 << m); for (int i = 0; i < (1 << m); i++) { for (int j = 0; j < m; j++) { if (i >> j & 1) { sum[i] += b[j]; } } } vector<int> dp; dp.push_back(0); for (int i = 0; i < n; i++) { vector<int> ndp; for (int j = 0; j < (1 << m); j++) { if (sum[j] == a[i]) { for (auto mask : dp) { if ((j & mask) == 0) { ndp.push_back(j | mask); } } } } sort(ndp.begin(), ndp.end()); ndp.erase(unique(ndp.begin(), ndp.end()), ndp.end()); swap(dp, ndp); } cout << (!dp.empty() ? "YES" : "NO") << '\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...