Submission #1100379

#TimeUsernameProblemLanguageResultExecution timeMemory
1100379mmd_matinBank (IZhO14_bank)C++17
100 / 100
76 ms4740 KiB
#include<bits/stdc++.h> using namespace std; const int N = 25; int a[N], b[N], p[N], mask[(1 << N)], n, m; void read() { cin >> n >> m; for (int t = 0; t < n; t++) { cin >> a[t]; p[t + 1] = p[t] + a[t]; } for (int i = 0; i < m; i++) cin >> b[i]; } void solve() { int ans = 0; for (int t = 0; t < (1 << m); t++) { int tmp = 0, sum = 0; for (int i = 0; i < m; i++) { if ((1 << i) & t) { tmp = max(tmp, mask[t - (1 << i)]); sum += b[i]; } } if (p[tmp + 1] == sum) tmp++; mask[t] = tmp; // cout << "mask : " << t << ' ' << tmp << '\n'; ans = max(ans, mask[t]); } if (ans == n) cout << "YES\n"; else cout << "NO\n"; } int main() { read(); 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...