Submission #1007998

#TimeUsernameProblemLanguageResultExecution timeMemory
1007998arashmemarBank (IZhO14_bank)C++17
100 / 100
70 ms4532 KiB
#include <bits/stdc++.h> using namespace std; long long int a[30], b[30]; int dp[(1 << 20) + 20], ps[30]; int main() { int n, m; cin >> n >> m; for (int i = 0;i < n;i++) { cin >> a[i]; } ps[0] = a[0]; for (int i = 1;i < n;i++) { ps[i] = ps[i-1] + a[i]; } for (int i = 0;i < m;i++) { cin >> b[i]; } for (long long int mask = 1; mask < (1 << m);mask++) { int c = 1; int s = 0; for (int i = 0;i < m;i++) { if (mask & c) { s += b[i]; dp[mask] = max(dp[mask], dp[mask - c]); } c *= 2; } if (s == ps[dp[mask]]) { dp[mask]++; } } if (dp[(1 << m) - 1] == n) { cout << "YES" << endl; } else { cout << "NO" << endl; } 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...