제출 #42937

#제출 시각아이디문제언어결과실행 시간메모리
42937funcsr은행 (IZhO14_bank)C++14
100 / 100
729 ms86908 KiB
#include <cstdio> #include <iostream> #include <algorithm> #include <string> #include <cstring> #include <vector> #include <queue> #include <set> #include <map> #include <cmath> #include <iomanip> #include <cassert> #include <bitset> using namespace std; typedef pair<int, int> P; #define rep(i, n) for (int i=0; i<(n); i++) #define all(c) (c).begin(), (c).end() #define uniq(c) c.erase(unique(all(c)), (c).end()) #define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin()) #define _1 first #define _2 second #define pb push_back #define INF 1145141919 #define MOD 1000000007 int N, M; int A[20], B[20]; int dp[21][1<<20]; signed main() { ios::sync_with_stdio(false); cin.tie(0); cin >> N >> M; rep(i, N) cin >> A[i]; rep(i, M) cin >> B[i]; rep(i, N+1) rep(j, 1<<M) dp[i][j] = -1; dp[0][0] = 0; rep(i, N) { rep(S, 1<<M) { if (dp[i][S] == -1) continue; rep(t, M) if (((S>>t)&1) == 0) dp[i][S|(1<<t)] = dp[i][S]+B[t]; } rep(S, 1<<M) if (dp[i][S] == A[i]) dp[i+1][S] = 0; } bool ok = false; rep(S, 1<<M) if (dp[N][S] == 0) ok = true; if (ok) cout << "YES\n"; else cout << "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...