제출 #735502

#제출 시각아이디문제언어결과실행 시간메모리
735502PoonYaPat은행 (IZhO14_bank)C++14
100 / 100
150 ms4608 KiB
#include <bits/stdc++.h> using namespace std; int n,m,qs[21],b[21],dp[1<<20]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); 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...