Submission #936530

#TimeUsernameProblemLanguageResultExecution timeMemory
936530tamir1Bank (IZhO14_bank)C++14
25 / 100
335 ms262144 KiB
#include<bits/stdc++.h> #define ff first #define ss second using namespace std; int n,m,i,j; vector<pair<int,int>> dp[(1<<20)]; int main(){ cin >> n >> m; vector<int> a(n); vector<int> b(m); dp[0].push_back({0,0}); for(i=0;i<n;i++) cin >> a[i]; for(i=0;i<m;i++) cin >> b[i]; for(i=1;i<(1<<m);i++){ for(j=0;j<m;j++){ if(i&(1<<j)){ for(pair<int,int> l:dp[i^(1<<j)]){ if(l.ss+b[j]>a[l.ff]) continue; if(l.ss+b[j]==a[l.ff]){ if(l.ff==n-1){ cout << "YES"; return 0; } dp[i].push_back({l.ff+1,0}); } else dp[i].push_back({l.ff,l.ss+b[j]}); } } } } 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...