Submission #1076957

#TimeUsernameProblemLanguageResultExecution timeMemory
1076957xnqsBank (IZhO14_bank)C++17
71 / 100
1043 ms20952 KiB
#include <iostream> #include <fstream> #include <vector> #include <queue> #include <utility> #include <algorithm> #include <cstring> int tgt_cnt, x; int tgt[25]; int arr[25]; char dp[20][1<<20]; bool sol(int pos, int mask) { if (pos==tgt_cnt) { return 1; } if (dp[pos][mask]!=-1) { return dp[pos][mask]; } bool ret = 0; for (int mask2 = 0; mask2 < (1<<x); mask2++) { if (mask2&mask) { continue; } int sum = 0; for (int i = 0; i < x; i++) { if (mask2&(1<<i)) { sum += arr[i]; } if (sum>tgt[pos]) { goto gtfo; } } if (sum==tgt[pos]) { ret |= sol(pos+1,mask|mask2); if (ret) { break; } } gtfo: continue; } return dp[pos][mask] = ret; } int main() { std::cin >> tgt_cnt >> x; for (int i = 0; i < tgt_cnt; i++) { std::cin >> tgt[i]; } for (int i = 0; i < x; i++) { std::cin >> arr[i]; } memset(dp,-1,sizeof(dp)); std::cout << ((sol(0,0)) ? "YES" : "NO") << "\n"; }

Compilation message (stderr)

bank.cpp: In function 'bool sol(int, int)':
bank.cpp:49:23: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   49 |  return dp[pos][mask] = ret;
      |         ~~~~~~~~~~~~~~^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...