Submission #168220

#TimeUsernameProblemLanguageResultExecution timeMemory
168220juggernautBank (IZhO14_bank)C++14
100 / 100
283 ms22660 KiB
#include<bits/stdc++.h> #define int long long int using namespace std; int n,m,a[21],b[20],mask,i,sum[(1<<20)]; bool dp[21][(1<<20)]; vector<vector<int>>g(21); void go(int pos,int mask){ if(dp[pos][mask])return; dp[pos][mask]=1; if(pos==n+1){ puts("YES"); exit(0); } for(int to:g[pos]) if((mask&to)==0)go(pos+1,mask|to); } main(){ scanf("%lld%lld",&n,&m); for(i=1;i<=n;i++)scanf("%lld",&a[i]); for(i=0;i<m;i++)scanf("%lld",&b[i]); for(mask=0;mask<(1<<m);mask++) for(i=0;i<m;i++)if(mask&(1<<i))sum[mask]+=b[i]; g[0].push_back(0); for(i=1;i<=n;i++) for(mask=0;mask<(1<<m);mask++) if(sum[mask]==a[i])g[i].push_back(mask); go(0,0); puts("NO"); }

Compilation message (stderr)

bank.cpp:17:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
bank.cpp: In function 'int main()':
bank.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld%lld",&n,&m);
     ~~~~~^~~~~~~~~~~~~~~~~~
bank.cpp:19:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(i=1;i<=n;i++)scanf("%lld",&a[i]);
                      ~~~~~^~~~~~~~~~~~~~
bank.cpp:20:26: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(i=0;i<m;i++)scanf("%lld",&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...