Submission #824338

#TimeUsernameProblemLanguageResultExecution timeMemory
824338kebineBank (IZhO14_bank)C++17
44 / 100
805 ms262144 KiB
#include<bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); set<vector<int>> dp; int n, m; cin >> n >> m; vector<int> a(n); dp.insert(a); for(int &p : a) cin >> p; while(m--) { int b; cin >> b; stack<vector<int>> st; for(auto p : dp) { for(int i=0; i<n; i++) { if(p[i]+b>a[i]) continue; p[i]+=b; st.push(p); p[i]-=b; } } while(!st.empty()) dp.insert(st.top()), st.pop(); } cout << (dp.count(a) ? "YES" : "NO") << '\n'; 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...