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 <iostream>
#include <vector>
using namespace std;
int main() {
int N, S;
cin >> N >> S;
vector<int> V(N), W(N), K(N);
for (int i = 0; i < N; ++i) {
cin >> V[i] >> W[i] >> K[i];
}
vector<long long> dp(S + 1, 0);
for (int i = 0; i < N; ++i) {
for (int k = 1; K[i] > 0; k <<= 1) {
int count = min(k, K[i]);
K[i] -= count;
for (int s = S; s >= W[i] * count; --s) {
dp[s] = max(dp[s], dp[s - W[i] * count] + V[i] * count);
}
}
}
cout << dp[S] << 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... |