제출 #916604

#제출 시각아이디문제언어결과실행 시간메모리
916604atom은행 (IZhO14_bank)C++17
19 / 100
1 ms348 KiB
#include "bits/stdc++.h" // @JASPER'S BOILERPLATE using namespace std; using ll = long long; #ifdef JASPER #include "debug.h" #else #define debug(...) 166 #endif const int N = 22; int n, m; int a[N], b[N]; bool dp[N][1 << N]; // dp(i, x): (1..i person with mask x of bank notes); signed main() { cin.tie(0) -> sync_with_stdio(0); cin >> n >> m; for (int i = 1; i <= n; ++i) cin >> a[i]; for (int j = 1; j <= m; ++j) cin >> b[j]; if (n == 1) { int sum = a[1]; vector <int> f(sum + 5, 0); f[0] = 1; for (int j = 1; j <= m; ++j) { for (int x = sum; x >= 0; --x) if (x >= b[j]) f[x] |= f[x - b[j]]; } cout << (f[sum]? "YES\n" : "NO\n"); } else cout << "NO\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...