Submission #819839

#TimeUsernameProblemLanguageResultExecution timeMemory
819839kanishk2606Bank (IZhO14_bank)C++17
0 / 100
1 ms1108 KiB
// uggjaa ped #include <bits/stdc++.h> using namespace std; #define ll long long #define loop(lcv, lower, upper) for (ll lcv = lower; lcv < upper; lcv++) bool help(ll i, ll mask, ll a[], ll left, ll b[], ll m, ll n) { if (i == n) return true; if (mask == 0) return false; bool ans = false; loop(j, 0, m) { if (((1 << j) & mask)) { if (left == b[j]) { if (i == n - 1) return true; ans = ans or help(i + 1, mask ^ (1 << j), a, a[i + 1], b, m, n); } else if (left > b[j]) { ans = ans or help(i, mask ^ (1 << j), a, left - b[j], b, m, n); } } } return ans; } void solve() { ll n, m; cin >> n >> m; ll a[n], b[m]; loop(i, 0, n) cin >> a[i]; loop(i, 0, m) cin >> b[i]; ll dp[n][1 << m] = {-1}; cout << help(0, (1 << m) - 1, a, a[0], b, m, n) << endl; } int main() { solve(); return 0; }

Compilation message (stderr)

bank.cpp: In function 'void solve()':
bank.cpp:41:8: warning: unused variable 'dp' [-Wunused-variable]
   41 |     ll dp[n][1 << m] = {-1};
      |        ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...