Submission #1100405

#TimeUsernameProblemLanguageResultExecution timeMemory
1100405King87arshiaBank (IZhO14_bank)C++14
100 / 100
75 ms8640 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; long long dp[(1 << m) + 10]; memset(dp, -1, sizeof dp); long long a[n + 5], b[m + 5], pt[n + 5]; for (int i = 0; i < n; i++) { cin >> a[i]; pt[i] = (i == 0? a[i]: pt[i - 1] + a[i]); } for (int i = 0; i < m; i++) cin >> b[i]; for (int mask = 0; mask < (1 << m); mask++) { long long sum = 0; for (int i = 0; i < m; i++) { if ((1 << i) & mask) dp[mask] = max(dp[mask], dp[mask ^ (1 << i)]), sum += b[i]; } if (sum == pt[dp[mask] + 1]) dp[mask]++; } if (dp[(1 << m) - 1] >= n - 1) 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...