Submission #1012937

#TimeUsernameProblemLanguageResultExecution timeMemory
1012937MohamedFaresNebiliBank (IZhO14_bank)C++14
100 / 100
85 ms8608 KiB
#include <bits/stdc++.h> using namespace std; int N, M; vector<int> A, B; int cur[(1 << 20)], lf[(1 << 20)]; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); memset(cur, -1, sizeof cur); cin >> N >> M; A = vector<int> (N), B = vector<int> (M); for(int l = 0; l < N; l++) cin >> A[l]; for(int l = 0; l < M; l++) cin >> B[l]; cur[0] = 0; for(int l = 1; l < (1 << M); l++) { for(int i = 0; i < M; i++) { if(!(l & (1 << i))) continue; int mask = l ^ (1 << i); if(cur[mask] == -1) continue; int G = lf[mask] + B[i]; if(G == A[cur[mask]]) { cur[l] = cur[mask] + 1; lf[l] = 0; } else if(G < A[cur[mask]]) { lf[l] = G; cur[l] = cur[mask]; } } if(cur[l] == N) { cout << "YES" << "\n"; return 0; } } cout << "NO" << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...