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 n,m;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> m;
assert(n == 1);
vector<int> s(n),c(m);
for(int &i : s) cin >> i;
for(int &i : c) cin >> i;
int maior = *max_element(s.begin(),s.end());
vector<int> dp(maior + 1,0);
dp[0] = 1;
for(int i : c)
for(int j = maior - i;j >= 0;j--)
dp[j + i] |= dp[j];
cout << (dp[s[0]] ? "YES" : "NO");
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... |