제출 #1134454

#제출 시각아이디문제언어결과실행 시간메모리
1134454JelalTkm은행 (IZhO14_bank)C++20
46 / 100
81 ms24904 KiB
#include <bits/stdc++.h> #pragma GCC optimize ("O3") #pragma GCC target ("sse4") using namespace std; #define int long long int const int N = 1e6 + 10; const int md = 1e9 + 7; const int INF = 1e18; int32_t main(int32_t argc, char *argv[]) { ios::sync_with_stdio(false); cin.tie(nullptr); int T = 1; // cin >> T; while (T--) { int n, m; cin >> n >> m; vector<int> a(n + 1), b(m + 1); for (int i = 1; i <= n; i++) cin >> a[i]; for (int j = 1; j <= m; j++) cin >> b[j]; if (n > m) { cout << "NO" << '\n'; continue; } vector<vector<int>> dp(n + 1, vector<int> ((1 << m) + 1)); for (int j = 0; j < (1 << m); j++) dp[0][j] = 1; string ans = "NO"; for (int i = 1; i <= n; i++) { for (int j = 1; j < (1 << m); j++) { int num = 0, sm = 0; for (int k = 0; k < m; k++) { if (((1 << k) & j)) { sm += b[k + 1]; } else num |= (1 << k); } if (sm == a[i] && dp[i - 1][num]) { dp[i][j] = 1; if (i == n) ans = "YES"; } if (dp[i][j]) for (int k = 0; k < m; k++) { dp[i][(j | (1 << k))] = dp[i][j]; } } } cout << ans << '\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...