제출 #936531

#제출 시각아이디문제언어결과실행 시간메모리
936531tamir1은행 (IZhO14_bank)C++14
100 / 100
240 ms98964 KiB
#include<bits/stdc++.h> #define ff first #define ss second using namespace std; int n,m,i,j; set<pair<int,int>> dp[(1<<20)]; int main(){ cin >> n >> m; vector<int> a(n); vector<int> b(m); dp[0].insert({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].insert({l.ff+1,0}); } else dp[i].insert({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...