제출 #875360

#제출 시각아이디문제언어결과실행 시간메모리
875360MisterReaper은행 (IZhO14_bank)C++17
0 / 100
3 ms8540 KiB
#include <bits/stdc++.h> using namespace std; using i64 = long long; pair <int, int> dp[1 << 20]; #define ONLINE_JUDGE void solve() { fill(dp, dp + (1 << 20), pair <int, int> {-1, 0}); int n, m; cin >> n >> m; vector <int> a(n); for(int &i : a) cin >> i; vector <int> b(m); for(int &i : b) cin >> i; dp[0] = {0, 0}; for(int mask = 1; mask < (1 << m); mask++) { for(int i = 0; i < m; i++) { if((mask >> i) & 1) { auto [num, left] = dp[mask ^ (1 << i)]; if(num == -1) continue; if(left + b[i] == a[num]) { dp[mask] = {num +1, 0}; } else if(left + b[i] < a[num]) { dp[mask] = {num, left + b[i]}; } } } if(dp[mask].first == n) { cerr << mask; cout << "Yes"; return; } } cout << "No"; return; } signed main() { #ifndef ONLINE_JUDGE freopen(".in", "r", stdin); freopen(".out", "w", stdout); #endif ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int t = 1; //cin >> t; for(int i = 1; i <= t; i++) { solve(); } 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...