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>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
int n,m;
cin >> n >> m;
int k;
cin >> k;
int a[m+1];
for (int i=1; i<=m; i++) {
cin >> a[i];
}
int dp[k+1];
memset(dp,0,sizeof(dp));
for (int i=1; i<=m; i++) {
if (a[i]<=k) {
dp[a[i]]=1;
}
}
dp[0]=1;
for (int i=1; i<=k; i++) {
for (int j=1; j<=n; j++) {
if (i-a[j]>=0) {
if (dp[i-a[j]]) {
dp[i]=1;
}
}
}
}
if (dp[k]) {
cout << "YES";
} else {
cout << "NO";
}
}
# | 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... |