제출 #1127550

#제출 시각아이디문제언어결과실행 시간메모리
1127550woohyun_jng은행 (IZhO14_bank)C++20
19 / 100
71 ms16844 KiB
#include <bits/stdc++.h> #define int long long #define MAX 21 using namespace std; int A[MAX], B[MAX], dp[2][1 << MAX], val[1 << MAX], res[MAX]; signed main() { ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(0); int N, M; cin >> N >> M; for (int i = 1; i <= N; i++) cin >> A[i]; for (int i = 0; i < M; i++) cin >> B[i]; for (int i = 0; i < (1 << M); i++) for (int j = 0; j < M; j++) if (i & (1 << j)) val[i] += B[j]; for (int i = 1; i <= N; i++) { fill(dp[i & 1], dp[i & 1] + (1 << M), 30000); for (int j = 0; j < (1 << M); j++) { if (val[j] - dp[i & 1 ^ 1][j] == A[i]) { dp[i & 1][j] = val[j], res[i] = 1; for (int k = 0; k < M; k++) if (!(j & (1 << k))) dp[i & 1][j | (1 << k)] = val[j]; } } } cout << (res[N] ? "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...