Submission #37598

#TimeUsernameProblemLanguageResultExecution timeMemory
37598alenam0161Bank (IZhO14_bank)C++14
100 / 100
226 ms14776 KiB
#include <bits/stdc++.h> using namespace std; #define ad push_back const int N = 20; int n,m; bool used[N][1<<N]; vector<int> comb[N]; int a[N],b[N]; void rek(int x,int clc){ if(x==n){ cout<<"YES";exit(0); } if(used[x][clc]==true)return; used[x][clc]=true; for(int to:comb[x]){ if(clc&to)continue; rek(x+1,clc|to); } } 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=0;i<(1<<m);++i){ int csum=0; for(int j=0;j<20;++j)if(i&(1<<j))csum+=b[j]; for(int j=0;j<n;++j)if(csum==a[j]){ comb[j].ad(i); } } rek(0,0); cout<<"NO"<<endl; return 0; }

Compilation message (stderr)

bank.cpp: In function 'int main()':
bank.cpp:22:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d%d",&n,&m);
    ~~~~~^~~~~~~~~~~~~~
bank.cpp:23:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    for(int i=0;i<n;++i)scanf("%d",a+i);
                        ~~~~~^~~~~~~~~~
bank.cpp:24:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    for(int i=0;i<m;++i)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...