Submission #191347

#TimeUsernameProblemLanguageResultExecution timeMemory
191347rzbtBank (IZhO14_bank)C++14
100 / 100
218 ms14576 KiB
#include <bits/stdc++.h> #define mp make_pair #define pb push_back #define F first #define S second #define all(x) x.begin(),x.end() #define MAXN 21 typedef long long ll; using namespace std; int n,m; int a[MAXN],b[MAXN]; vector<int> moze[MAXN]; bool dp[MAXN][1<<MAXN]; void resi(int koji,int maska){ //printf(" %d %d\n",koji,maska); if(koji==n){ printf("YES"); exit(0); } if(dp[koji][maska])return; dp[koji][maska]=true; for(auto x:moze[koji]) if(!(x & maska) && !dp[koji+1][x|maska]) resi(koji+1,x|maska); } int main() { scanf("%d %d", &n, &m); for(int i=0;i<n;i++) scanf("%d",a+i); for(int i=0;i<m;i++) scanf("%d",b+i); for(int i=1;i<(1<<m);i++){ int zbir=0; for(int j=0;j<m;j++){ if(i&(1<<j)){ zbir+=b[j]; } } //printf(" %d %d\n",i,zbir); for(int j=0;j<n;j++) if(a[j]==zbir)moze[j].pb(i); } resi(0,0); printf("NO"); return 0; }

Compilation message (stderr)

bank.cpp: In function 'int main()':
bank.cpp:34:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &n, &m);
     ~~~~~^~~~~~~~~~~~~~~~~
bank.cpp:36:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",a+i);
         ~~~~~^~~~~~~~~~
bank.cpp:38:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",b+i);
         ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...