제출 #864107

#제출 시각아이디문제언어결과실행 시간메모리
86410720163070은행 (IZhO14_bank)C++14
0 / 100
1 ms512 KiB
#include <bits/stdc++.h> using namespace std; const int N=110; int n,m; int a[N],b[N]; int main() { cin>>n>>m; for(int i=1;i<=n;i++) cin>>a[i]; for(int i=1;i<=m;i++) cin>>b[i]; vector<int> left(1<<m,-1); vector<int> cover(1<<m,-1); left[0]=0; cover[0]=0; for(int s=0;s<(1<<m);s++) { for(int last=1;last<=m;last++) { if((s&(1<<last))==0) continue; int prev=s&~(1<<last); if(cover[prev]==-1) continue; int newamt=left[prev]+b[last]; int curt=a[cover[prev]]; if(newamt<curt) { cover[s]=cover[prev]; left[s]=newamt; } else if(newamt==curt) { cover[s]=cover[prev]+1; left[s]=0; } if(cover[s]==n) { cout<<"YES"; } else cout<<"NO"; return 0; } } 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...