Submission #1088642

#TimeUsernameProblemLanguageResultExecution timeMemory
1088642vjudge1Bank (IZhO14_bank)C++17
100 / 100
100 ms8652 KiB
#include <bits/stdc++.h> using namespace std; using pii = pair<int,int>; const int maxn = 20,inf = 1e9; int n,m; pii dp[1 << maxn]; int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cin >> n >> m; vector<int> s(n),c(m); for(int &i : s) cin >> i; for(int &i : c) cin >> i; for(int i = 0;i < (1 << m);i++) dp[i] = {0,0}; for(int i = 1;i < (1 << m);i++) for(int j = 0;j < m;j++) if(i & (1 << j)){ int last = i ^ (1 << j); pii x = dp[last]; x.second += c[j]; if(x.second == s[x.first]){ x.first++; x.second = 0; } if(x.first == n){ cout << "YES"; return 0; } dp[i] = max(dp[i],x); } 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...