#include <bits/stdc++.h>
using namespace std;
int main()
{
int s, n; cin >> s >> n;
int dp[s + 10];
for(int i = 0; i < n; i++)
{
int v , w , k; cin >> v >> w >> k;
for (int j = s; j >= 0; j--)
{
for(int c = 1; c <= k and c * w <= j; c++)
{
dp[j] = max(dp[j] , dp[j - c * w] + c * 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... |