Submission #1115612

#TimeUsernameProblemLanguageResultExecution timeMemory
1115612tudor_costinBank (IZhO14_bank)C++11
19 / 100
67 ms16464 KiB
#include <bits/stdc++.h> using namespace std; const int Nmax=1005; vector<int> v[20*Nmax]; int dp[25][(1<<21)]; int sum[1<<21]; int a[25],b[25]; int main() { int n,m; cin>>n>>m; for(int i=1;i<=n;i++) cin>>a[i]; for(int j=1;j<=m;j++) cin>>b[j]; for(int mask=0;mask<(1<<m);mask++) { for(int i=0;i<m;i++) { if((mask&(1<<i))!=0) { sum[mask]+=b[i]; } } v[sum[mask]].push_back(mask); } int S=0; dp[0][0]=1; for(int i=0;i<n;i++) { for(int mask=0;mask<(1<<m);mask++) { if(dp[i][mask]==1) { for(int u:v[a[i+1]]) { if((u&mask)==0) { dp[i+1][mask|u]=1; if(i+1==n) { cout<<"YES"<<'\n'; return 0; } } } } } } cout<<"NO"<<'\n'; return 0; }

Compilation message (stderr)

bank.cpp: In function 'int main()':
bank.cpp:26:9: warning: unused variable 'S' [-Wunused-variable]
   26 |     int S=0;
      |         ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...