제출 #691883

#제출 시각아이디문제언어결과실행 시간메모리
691883balthazar은행 (IZhO14_bank)C++14
0 / 100
1 ms424 KiB
#include <iostream> #include <vector> using namespace std; int main() { int a; int b; cin>>a>>b; vector<int>av(a); vector<int>bv(b); for(int i=0;i<a;i++){ cin>>av[i]; } for(int i =0;i<b;i++){ cin>>bv[i]; } vector<pair<int, int>> dp(1<<b,{-1,0}); dp[0]={0,0}; for(int s=1;s<(1<<b);s++){ for(int i = 0;i<b;i++){ if(s>>i&1){ auto prev = dp[s^(1<<i)]; int valide = prev.first; int rest = prev.second; if(rest == -1)continue; if(rest + bv[i]==av[valide]){ dp[s].first+=1; dp[s].second=0; } if(rest+bv[i]<av[valide]){ dp[s].second+=bv[i]; } if(dp[s].first == a){ cout<<"YES"; return 0; } } } } cout<<"N0"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...