제출 #911352

#제출 시각아이디문제언어결과실행 시간메모리
911352ilef은행 (IZhO14_bank)C++14
100 / 100
108 ms8644 KiB
#include<bits/stdc++.h> using namespace std; int main(){ int n,m; cin>>n>>m; int b[m]; int a[n]; for(int i=0;i<n;i++){ cin>>a[i]; } for(int i=0;i<m;i++){ cin>>b[i]; } vector<int>covered(1<<m,-1); vector<int>left(1<<m,-1); left[0]=0; covered[0]=0; for(int mask=1;mask<(1<<m);mask++){ for(int j=0;j<m;j++){ if((1<<j)&mask && covered[mask^(1<<j)]!=-1){ int msk=mask^(1<<j); int cur=a[covered[msk]]; int amt=left[msk]+b[j]; if(amt<cur){ covered[mask]=covered[msk]; left[mask]=amt; } else if(amt==cur){ covered[mask]=covered[msk]+1; left[mask]=0; } } } if(covered[mask]==n){ cout<<"YES"<<endl; return 0; } } cout<<"NO"<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...