제출 #689972

#제출 시각아이디문제언어결과실행 시간메모리
689972balthazar은행 (IZhO14_bank)C++14
0 / 100
1 ms340 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]; } pair<int, int> dp[1<<b]; 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 + bv[i]>av[valide])rest =bv[i]; if(rest + bv[i]==av[valide]){ valide+=1; rest=0; } if(rest+bv[i]<av[valide]){ rest+=bv[i]; } dp[s]=max(dp[s], make_pair(valide, rest)); 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...