Submission #410528

#TimeUsernameProblemLanguageResultExecution timeMemory
410528FarriusBank (IZhO14_bank)C++11
0 / 100
1 ms332 KiB
#include <bits/stdc++.h> using namespace std; int main () { int n, m; cin >> n >> m; int ar[n], br[m]; for (int i = 0; i < n; i++) { cin >> ar[i]; } for (int i = 0; i < m; i++) { cin >> br[i]; } vector<int> dp(1<<n), cr; cr.push_back(0); for (int i = 0; i < n; i++) { cr.push_back(cr.back() + ar[i]); } dp[0] = 1; for (int msk = 0; msk < (1<<m); msk++) { if (dp[msk]) { int cur = 0; for (int j = 0; j < m; j++) { if ((msk>>j) & 1) { cur += br[j]; } } int in = 0; while (in + 1 < (int) cr.size() && cr[in + 1] <= cur) in++; if (in == (int) cr.size() - 1) { cout << "YES" << '\n'; return 0; } for (int j = 0; j < m; j++) { if ((msk>>j) & 1) continue; if (cur + br[j] <= cr[in]) { dp[msk^(1<<j)] = 1; } } } } 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...