#include <iostream>
using namespace std;
struct ura{
int v, w, k;
}v[100001];
int dp[2001];
int main()
{
int s, n;
cin >> s >> n;
for(int i = 1; i <= n; i++){
cin >> v[i].v >> v[i].w >> v[i].k;
}
for(int i = 1; i <= n; i++){
for(int j = s; j >= 1; j--){
for(int k = 1; k <= v[i].k; k++){
if(j + (k * v[i].w) <= s){
dp[j + (k * v[i].w)] = max(dp[j + (k * v[i].w)], dp[j] + (k * v[i].v));
}
}
}
}
cout << dp[s] << "\n";
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... |