제출 #783802

#제출 시각아이디문제언어결과실행 시간메모리
783802nghiaaa은행 (IZhO14_bank)C++17
44 / 100
76 ms212 KiB
#include <bits/stdc++.h> using namespace std; multiset<int> haha; int n,m,a[30],BIT[30]; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); //freopen("bank.in","r",stdin); //freopen("bank.out","w",stdout); cin>>n>>m; int check=0; for (int i=0;i<n;i++) { int ai; cin>>ai; haha.insert(ai); } for (int i=0;i<m;i++) cin>>a[i]; //sort(a,a+m); BIT[0]=1; for (int i=1;i<25;i++) BIT[i]=BIT[i-1]<<1; for (int mask=1;mask<BIT[m];mask++) { if (mask&check) continue; int sum=0; for (int i=0;i<m;i++) if (mask&BIT[i]) sum+=a[i]; if (haha.find(sum)!=haha.end()) { haha.erase(haha.find(sum)); check|=mask; } } if (haha.size()) cout<<"NO"; else cout<<"YES"; return 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...