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 s, n;
cin >> s >> n;
vector<int> v(n),
w(n),
q(n);
for(int i = 0; i < n; i++)
cin >> v[i]
>> w[i]
>> q[i];
vector<int> dp(s + 1, 0);
for(int i = 0; i < n; i++)
for(int j = s; j >= w[i]; j--)
for(int k = 0; k <= min(j / w[i], q[i]); k++)
dp[j] = max(dp[j], dp[j - k * w[i]] + k * v[i]);
cout << dp[s];
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... |