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;
#define int long long
signed main() {
cin.tie(nullptr)->sync_with_stdio(false);
int n, k;
cin >> n >> k;
vector<int> arr(n);
for(int i = 0; i < n; ++i) cin >> arr[i];
vector<vector<bool>> dp(n + 1, vector<bool>(k + 1, false));
dp[0][0] = true;
for(int i = 1; i <= n; ++i) {
for(int j = 0; j <= k; ++j) {
dp[i][j] = dp[i - 1][j] || (j >= arr[i - 1] && dp[i - 1][j - arr[i - 1]]);
}
}
int ans = 0;
for(int j = 0; j <= k; ++j) {
if(dp[n][j]) ans++;
}
cout << ans;
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... |
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |