제출 #743711

#제출 시각아이디문제언어결과실행 시간메모리
743711Dead_Inside7은행 (IZhO14_bank)C++17
100 / 100
128 ms16724 KiB
#include <bits/stdc++.h> using namespace std; int main() { // ifstream cin("bank.in"); // ofstream cout("bank.out"); int n,m; cin>>n>>m; vector<int> a(n),b(m); for(auto&v:a) cin>>v; for(auto&v:b) cin>>v; bool cc=false; vector<pair<long long,long long>> dp(1<<m,{0,0}); dp[0]={0,0}; for(int i=1;i<(1<<m);i++){ for(int j=0;j<m;j++){ if(i&(1<<j)){ pair<long long,long long> mx; mx=dp[i^(1<<j)]; if(mx.first==-1) continue; mx.second+=b[j]; if(a[mx.first] == mx.second){ mx.second=0; mx.first++; } dp[i] = max(dp[i],mx); } } if(dp[i].first == n){ cc=true;break; } } if(cc) cout<<"YES"; else cout<<"NO"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...