#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int s, n;
cin >> s >> n;
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 a=s; a>=w; a--) {
dp[a] = max(dp[a], dp[a - 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... |