제출 #1100901

#제출 시각아이디문제언어결과실행 시간메모리
1100901nguyenkhangninh99은행 (IZhO14_bank)C++14
100 / 100
73 ms4540 KiB
#include <bits/stdc++.h> using namespace std; const int maxmask = (1 << 20) + 5, maxn = 22; int dp[maxmask], a[maxn], b[maxn], pref[maxn]; void solve(){ int n, m; cin >> n >> m; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < m; i++) cin >> b[i]; pref[0] = a[0]; for(int i = 1; i < n; i++) pref[i] = pref[i - 1] + a[i]; for (int mask = 0; mask < (1 << m); mask++) { int sum = 0; for (int i = 0; i < m; i++) { if (mask & (1 << i)){ dp[mask] = max(dp[mask], dp[mask ^ (1 << i)]); sum += b[i]; } } if (sum == pref[dp[mask]]) dp[mask]++; } if (dp[(1 << m) - 1] < n) cout << "NO\n"; else cout << "YES\n"; } signed main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...