#include<bits/stdc++.h>
using namespace std;
int main() {
int n, W;
cin >> n >> W;
vector<int> dp(W + 1, 0);
for (int i = 0; i < n; ++i) {
int wi, vi, ai;
cin >> wi >> vi >> ai;
for (int k = 1; ai > 0; k *= 2) {
int num = min(k, ai);
ai -= num;
int weight = num * wi;
int value = num * vi;
for (int j = W; j >= weight; --j) {
dp[j] = max(dp[j], dp[j - weight] + value);
}
}
}
cout << dp[W] << 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... |