제출 #936520

#제출 시각아이디문제언어결과실행 시간메모리
936520tamir1은행 (IZhO14_bank)C++14
44 / 100
63 ms408 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(m); 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...