Submission #1114625

#TimeUsernameProblemLanguageResultExecution timeMemory
1114625ChinguunBank (IZhO14_bank)C++14
100 / 100
169 ms8688 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int N = 21; int n, m, pre[N], b[N], dp[(1 << N)], sum; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m; for (int i = 0; i < n; i++) { cin >> pre[i]; pre[i] += pre[i - 1]; } for (int i = 0; i < m; i++) { cin >> b[i]; } for (int mask = 1; mask < (1 << m); mask++) { sum = 0; for (int i = 0; i < m; i++) { if ((mask & (1 << i))) sum += b[i]; } for (int i = 0; i < m; i++) { if ((mask & (1 << i))) { int x = dp[mask ^ (1 << i)]; dp[mask] = max (dp[mask], x + (pre[x] == sum)); } } } if (dp[(1 << m) - 1] == n) cout << "YES"; else cout << "NO"; 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...