This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |