제출 #720077

#제출 시각아이디문제언어결과실행 시간메모리
720077ovidiush11은행 (IZhO14_bank)C++14
44 / 100
6 ms340 KiB
#include <bits/stdc++.h> using namespace std; int st[20],n,m; vector<int> a,b; bool sum(int s,int k) { if(s == 0)return 1; if(s < 0)return 0; for(int i = k;i < m;i++) { if(st[i] == 0) { st[i] = 1; if(sum(s - b[i],i+1))return 1; st[i] = 0; } } return 0; } int main() { cin>>n>>m; for(int i = 0;i < m;i++)st[i] = 0; a.resize(n);b.resize(m); for(int i = 0;i < n;i++)cin>>a[i]; for(int i = 0;i < m;i++)cin>>b[i]; sort(a.begin(),a.end()); sort(b.rbegin(),b.rend()); for(int i = 0;i < n;i++) { if(!sum(a[i],0)) { cout<<"NO"<<endl; return 0; } } cout<<"YES"<<endl; 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...