Submission #936519

#TimeUsernameProblemLanguageResultExecution timeMemory
936519tamir1Bank (IZhO14_bank)C++14
0 / 100
2 ms600 KiB
#include<bits/stdc++.h> using namespace std; int n,m,i,j,l,suma,sumb,x; int main(){ cin >> n >> m; vector<int> a(n); vector<int> b(n); for(i=0;i<n;i++) cin >> a[i],suma+=a[i]; for(i=0;i<m;i++) cin >> b[i],sumb+=b[i]; if(suma>sumb || a.size()>b.size()){ cout << "NO"; return 0; } //sort(a.rbegin(),a.rend()); //sort(a.rbegin(),a.rend()); for(i=0;i<n;i++){ for(j=0;j<m;j++){ if(a[i]==b[j]){ a[i]=0; b[j]=0; } } } //for(i=0;i<n;i++) cout << a[i] << " "; for(i=0;i<n;i++){ x=a[i]; bool ok=0; for(j=0;j<(1<<m);j++){ int sum=0; for(l=0;l<m;l++){ if(j&(1<<l)) sum+=b[l]; } if(sum==x){ ok=1; for(l=0;l<m;l++){ if(j&(1<<l)) b[l]=0; } break; } } if(!ok){ cout << "NO"; return 0; } } cout << "YES"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...