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() {
int s, n;
cin >> s >> n;
vector<int> dp(s+1, 0);
for (int i = 0; i < n; i++) {
int v, w, k;
cin >> v >> w >> k;
for (int j = 0; j < k; j++) {
for (int r = s; r >= w; r--) {
if (dp[r] < dp[r-w] + v) {
dp[r] = dp[r-w] + v;
}
}
}
}
cout << dp[s] << "\n";
}
# | 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... |