Submission #813186

#TimeUsernameProblemLanguageResultExecution timeMemory
813186exodus_Bank (IZhO14_bank)C++14
71 / 100
1077 ms90676 KiB
#include<bits/stdc++.h> using namespace std; int N,M; vector<vector<int>>simp(21, vector<int>(1048577, -1)); vector<int>sum[40001]; int pip[21]; bool can = false; void dp(int idx, int mask) { if(idx > N-1) { can = true; return; } for(auto x:sum[pip[idx]]) { int ses = mask&x; if(ses == 0) { int lanj = mask|x; dp(idx+1, lanj); } } } int main() { cin >> N >> M; vector<int>vek(M); for(int i=0; i<N; i++) { cin >> pip[i]; } for(int i=0; i<M; i++) { cin >> vek[i]; } bool ada=false; for(int i=0; i<N; i++) { for(int mask=0; mask<(1<<M); mask++) { int sm=0; for(int k=0; k<M; k++) { if((mask>>k)&1 == true) sm+=vek[k]; } if(sm==pip[i]) sum[pip[i]].push_back(mask); } } dp(0,0); if(can) cout << "YES"; else cout << "NO"; return 0; }

Compilation message (stderr)

bank.cpp: In function 'int main()':
bank.cpp:36:32: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
   36 |                 if((mask>>k)&1 == true) sm+=vek[k];
      |                              ~~^~~~~~~
bank.cpp:31:10: warning: unused variable 'ada' [-Wunused-variable]
   31 |     bool ada=false;
      |          ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...