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() {
ios::sync_with_stdio(false);
cin.tie(0);
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 s = S; s >= 0; --s) {
for (int j = 1; j*w <= s and j <= k; ++j) {
dp[s] = max(dp[s], dp[s-j*w]+j*v);
}
}
}
cout << dp[S] << endl;
}
# | 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... |