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>
#include <climits>
#include <vector>
using namespace std;
int main(int argc, char *argv[]) {
int s, n;
cin >> s >> n;
vector<int> dp(s + 1, INT_MIN);
dp[0] = 0;
int result = 0;
for (int i = 0; i < n; i++) {
int v, w, k;
cin >> v >> w >> k;
for (int q = s; q >= w; q--) {
for (int j = 1; j <= k; j++) {
if (q - j * w < 0)
continue;
dp[q] = max(dp[q], dp[q - j * w] + j * v);
}
result = max(result, dp[q]);
}
}
cout << result << endl;
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... |