Submission #1090867

#TimeUsernameProblemLanguageResultExecution timeMemory
1090867vjudge1Bank (IZhO14_bank)C++17
100 / 100
582 ms82528 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int,int>; using tii = tuple<int,int,int>; const int maxn = 2e1; int n,m,s[maxn],c[maxn],dp[maxn][1 << maxn]; int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); cin >> n >> m; for(int i = 0;i < n;i++) cin >> s[i]; for(int i = 0;i < m;i++) cin >> c[i]; memset(dp,-1,sizeof dp); dp[0][0] = 0; for(int i = 0;i < n;i++) for(int mask = 0;mask < (1 << m);mask++) if(dp[i][mask] != -1){ if(dp[i][mask] == s[i]){ if(i == n - 1){ cout << "YES"; return 0; } else dp[i + 1][mask] = 0; } for(int j = 0;j < m;j++) if(!(mask & (1 << j))) dp[i][mask | (1 << j)] = dp[i][mask] + c[j]; } 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...