제출 #955044

#제출 시각아이디문제언어결과실행 시간메모리
955044AliHasanli은행 (IZhO14_bank)C++17
100 / 100
137 ms4756 KiB
#include <bits/stdc++.h> using namespace std; int n,m,qs[21],b[21],dp[1<<20]; int main() { cin>>n>>m; for(int i=0;i<n;i++)cin>>qs[i],qs[i]+=qs[i-1]; for(int i=0;i<m;i++)cin>>b[i]; for(int mask=1;mask<(1<<m);mask++) { int sum=0; for(int j=0;j<m;j++)if(mask&(1<<j))sum+=b[j]; for(int j=0;j<m;j++)if(mask&(1<<j))dp[mask]=max(dp[mask],dp[mask^(1<<j)]+(qs[dp[mask^(1<<j)]]==sum)); } if(dp[(1<<m)-1]==n)cout<<"YES"; else cout<<"NO"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...